Skip to content

Instantly share code, notes, and snippets.

@ltciro
Created October 29, 2018 08:57
Show Gist options
  • Save ltciro/3ab19bcd4ae2718b2d47f921b8a6e858 to your computer and use it in GitHub Desktop.
Save ltciro/3ab19bcd4ae2718b2d47f921b8a6e858 to your computer and use it in GitHub Desktop.
const Ix = require('ix');
async function* arrGen() {
yield 1;
yield 2;
yield 4;
}
const results = Ix.AsyncIterable.from(arrGen())
.filter(x => x % 2 === 0)
.map(x => x * 2);
async function arrReadFromIterator() {
// leé los values del async iterator con la sentencia for...of
for await (const n of results ){
console.log(n)
}
}
arrReadFromIterator()
//4
//8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment