UNPKG

es-toolkit

Version:

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

21 lines 772 B
//#region src/set/filter.d.ts /** * Filters a Set based on a predicate function. * * This function takes a Set and a predicate function, and returns a new Set containing * only the elements for which the predicate function returns true. * * @template T - The type of elements in the Set. * @param set - The Set to filter. * @param callback - A predicate function that tests each element. * @returns A new Set containing only the elements that satisfy the predicate. * * @example * const set = new Set([1, 2, 3, 4, 5]); * const result = filter(set, (value) => value > 2); * // result will be: * // Set(3) { 3, 4, 5 } */ declare function filter<T>(set: Set<T>, callback: (value: T, value2: T, set: Set<T>) => boolean): Set<T>; //#endregion export { filter };