Emits indexed values that pass the predicate test.
import {pipe, indexBy} from 'iter-ops';const i = pipe( [12, 7, 30, 9], indexBy(a => a % 2 === 0) // index even numbers);console.log(...i); //=> {index: 0, value: 12}, {index: 2, value: 30} Copy
import {pipe, indexBy} from 'iter-ops';const i = pipe( [12, 7, 30, 9], indexBy(a => a % 2 === 0) // index even numbers);console.log(...i); //=> {index: 0, value: 12}, {index: 2, value: 30}
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
Emits indexed values that pass the predicate test.
Note that the predicate can only return a
Promise
inside an asynchronous pipeline, or else thePromise
will be treated as a truthy value.