Takes values until the predicate test succeeds. The value for which predicate succeeds is excluded.
import {pipe, takeUntil} from 'iter-ops';const i = pipe( [1, 2, 3, 4, 5], takeUntil(a => a > 2) // take until value > 2);console.log(...i); //=> 1, 2 Copy
import {pipe, takeUntil} from 'iter-ops';const i = pipe( [1, 2, 3, 4, 5], takeUntil(a => a > 2) // take until value > 2);console.log(...i); //=> 1, 2
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 until the predicate test succeeds. The value for which predicate succeeds is excluded.
Note that the predicate can only return a
Promise
inside an asynchronous pipeline, or else thePromise
will be treated as a truthy value.