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 (19 loc) 797 B
/** * 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<T>} set - The Set to filter. * @param {(value: T, value2: T, set: Set<T>) => boolean} callback - A predicate function that tests each element. * @returns {Set<T>} 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>; export { filter };