nice-loops
v1.0.4
Published
Array iterators that yield to the event-loop periodically
Downloads
2
Readme
nice-loops
A spin on common Array methods like forEach, map, reduce, that periodically yield to the event loop
Implemented
forEach
map
reduce
find
some
every
Ending Iteration
Unlike in regular JavaScript, all iterations can be terminated early. In the callback function, returning the EndIteration symbol will stop iteration. At the moment you'll need to read the source to see what gets returned.
import { map, symbol } from "nice-loops"
await map([1, 2, 3, 4, 5], (n => (n < 3) ? (n * 2) : symbol.EndIteration) //=> [2, 4]