Takes values while the predicate test succeeds.
import {pipe, takeWhile} from 'iter-ops';const i = pipe( [1, 2, 3, 4, 5, 6, 7, 8, 9], takeWhile(a => a < 5) // take while value < 5);console.log(...i); //=> 1, 2, 3, 4 Copy
import {pipe, takeWhile} from 'iter-ops';const i = pipe( [1, 2, 3, 4, 5, 6, 7, 8, 9], takeWhile(a => a < 5) // take while value < 5);console.log(...i); //=> 1, 2, 3, 4
Note that the predicate can only return a Promise inside an asynchronous pipeline, or else the Promise will be treated as a truthy value.
Promise
Takes values while the predicate test succeeds.
Note that the predicate can only return a
Promise
inside an asynchronous pipeline, or else thePromise
will be treated as a truthy value.