UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

13 lines (12 loc) 399 B
import { combineEagerAndLazyFunctions, createLazyFunction } from "../_internal/lazy.mjs"; //#region src/fp/array/filter.ts function filter(predicate) { function filterEager(array) { return array.filter(predicate); } return combineEagerAndLazyFunctions(filterEager, createLazyFunction((value, index, emit) => { if (predicate(value, index)) emit(value); })); } //#endregion export { filter };