0.0.3 • Published 10 years ago

fileliststream v0.0.3

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

fileliststream

Given a FileList, turn it into a FileListStream.

example

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

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

function noop(name) {
  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
  • dataurl
  • arraybuffer
  • text