Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created June 24, 2015 12:53
Show Gist options
  • Save stepankuzmin/e31c8d598f617e0a3837 to your computer and use it in GitHub Desktop.
Save stepankuzmin/e31c8d598f617e0a3837 to your computer and use it in GitHub Desktop.
Babel.js iterable FileList
function iterableFileList(fileList) {
return Object.assign({
__proto__: fileList.__proto__,
[Symbol.iterator]() {
let nextIndex = 0;
return {
next() {
return nextIndex < fileList.length ?
{done: false, value: fileList[nextIndex++]} :
{done: true};
}
}
}
}, fileList)
}
@stepankuzmin
Copy link
Author

…or you can simply iterate over Array.from(fileList)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment