Created
June 24, 2015 12:53
-
-
Save stepankuzmin/e31c8d598f617e0a3837 to your computer and use it in GitHub Desktop.
Babel.js iterable FileList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
…or you can simply iterate over
Array.from(fileList)