demo · v146
Lazy pipeline builder
Build a pipeline by selecting source iterables (array, generator, Set, Map, an infinite Fibonacci), choosing iterator helpers (map, filter, take, drop), and toggling the strategy: Iterator.concat() or eager spread. The runner reports the produced values, the number of pulls each source served, and the peak intermediate-array size.
The interesting test is putting an infinite source after a finite one. Iterator.concat() pulls lazily, so a final .take(5) will never touch later sources once enough values have been produced. If the active source is a generator, early stop calls its .return() hook so finally blocks can clean up.
Iterator.concat() is sync-only: it composes sources with Symbol.iterator. ReadableStream, event, and network feeds are async pull patterns; use for await, async iterator utilities, or Streams APIs instead of passing them to this synchronous pipeline.
Sources
nums
[10, 20, 30]
tags
new Set(['a','b'])
counter
function* g() { let i = 100; while (true) yield i++; }
scores
new Map([['ada',95],['kai',82]]).entries()
banner
'hi!'
fib∞
function* fib() { let a=1,b=1; while(true) { yield a; [a,b]=[b,a+b]; } }