README
Converts a once iterable to many. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
This is part of package extra-iterable.
This is browserified, minified version of @extra-iterable/many.
It is exported as global variable iterable_many.
CDN: unpkg, jsDelivr.
iterable.many(x, [now]);
// x: an iterable
// now: consume immediately? (false)
const iterable = require("extra-iterable");
var x = [1, 2, 3].values();
[...x, ...x];
// [ 1, 2, 3 ]
// ("x" cant be iterated multiple times)
function* from1ToN(n) {
for(var i=1; i<=n; i++) {
console.log("yielding", i);
yield i;
}
}
var x = from1ToN(3);
var y = iterable.many(x);
for(var v of y) console.log("read", v);
// yielding 1
// read 1
// yielding 2
// read 2
// yielding 3
// read 3
for(var v of y) console.log("read", v);
// read 1
// read 2
// read 3
var x = from1ToN(3);
var y = iterable.many(x, true);
// yielding 1
// yielding 2
// yielding 3
for(var v of y) console.log("read", v);
// read 1
// read 2
// read 3
for(var v of y) console.log("read", v);
// read 1
// read 2
// read 3