nyc-bookstores/node_modules/filesystem-browserify/node_modules/fileliststream
2013-05-27 13:45:59 -07:00
..
.npmignore all da files 2013-05-27 13:45:59 -07:00
bundle.js all da files 2013-05-27 13:45:59 -07:00
example.html all da files 2013-05-27 13:45:59 -07:00
example.js all da files 2013-05-27 13:45:59 -07:00
index.js all da files 2013-05-27 13:45:59 -07:00
package.json all da files 2013-05-27 13:45:59 -07:00
README.md all da files 2013-05-27 13:45:59 -07:00

fileliststream

Given a FileList, turn it into a FileListStream.

install

Use it with npm & browserify

$ npm install fileliststream

example

const FileListStream = require('fileliststream');
const body = document.body;

// make it so console can be piped to.
console.write = console.log;

function noop(event) {
  event.preventDefault();
  event.stopPropagation();
  return false;
};

['dragenter',
 'dragleave',
 'dragexit',
 'dragover'
].forEach(function (eventType) {
   body.addEventListener(eventType, noop);
});

body.addEventListener('drop', function (event) {
  event.stopPropagation();
  event.preventDefault();

  const fileList = FileListStream(event.dataTransfer.files);

  fileList.files.map(function(file) {
     file.pipe(console);
  });

  return false;
});

usage

FileListStream(fileList, [options])

options currently has one possible parameter, output. Possible values are:

  • binary [default]
  • dataurl
  • arraybuffer
  • text