lazy.js
lazy.js copied to clipboard
Support for native asynchronous generators
async function* iterateDir(dir) {
let list = await fs.readdir(dir); // fs-promise implementation of readdir
for (let file of list) {
yield file;
}
}
Lazy.generate(iterateDir('./out'))
.async(1000) // specifies a 1-second interval between each element
.map(function(x) { return String.fromCharCode(x + 65); })
.take(26)
.each(function(char) { console.log(char); });
I think generators are super suitable to be used with lazy.js . Hope this is going to be implemented! :)