mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +08:00
In a fused helper chain, take(n) sets the chain's done flag as it delivers its nth value, so nothing is pulled after it. A flatMap later in the chain tested the same flag in its inner walk and stopped after the first flattened value: gen().take(2).flatMap((x) => [x, x + 10]) gave [0, 10] where Node gives [0, 10, 1, 11]. A flatMap stage after a take now holds the flag while it walks its inner iterable, and sets it again afterwards. A terminal that short-circuits or a take later in the chain still stops the inner walk.