Filters elements in an input sync iterable based on a given predicate function. Returns a new sync iterable with elements that satisfy the predicate.
A function that accepts an input sync iterable and returns a new sync iterable with the filtered elements.
const input = [1, 2, 3, 4];const isEven = (x: number) => x % 2 === 0;const filteredSyncIterable = filterSync<number>(isEven)(input);for (const x of filteredSyncIterable) { console.log(x); // Logs 2, 4}
Available as filter when imported from peter-piper/sync.
filter
peter-piper/sync
The type of elements in the input sync iterable.
A predicate function to test each element of the input sync iterable.
Generated using TypeDoc
Filters elements in an input sync iterable based on a given predicate function. Returns a new sync iterable with elements that satisfy the predicate.
Returns
A function that accepts an input sync iterable and returns a new sync iterable with the filtered elements.
Example
Remarks
Available as
filter
when imported frompeter-piper/sync
.