source: node_modules/es-toolkit/dist/set/find.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1018 bytes
Line 
1/**
2 * Finds the first element in a Set for which the predicate function returns true.
3 *
4 * This function iterates through the elements of the Set and returns the first
5 * element for which the predicate function returns true. If no element satisfies the predicate,
6 * it returns undefined.
7 *
8 * @template T - The type of elements in the Set.
9 * @param {Set<T>} set - The Set to search.
10 * @param {(value: T, value2: T, set: Set<T>) => boolean} doesMatch - A predicate function that tests each element.
11 * @returns {T | undefined} The first element that satisfies the predicate, or undefined if none found.
12 *
13 * @example
14 * const set = new Set([
15 * { name: 'apple', quantity: 10 },
16 * { name: 'banana', quantity: 5 },
17 * { name: 'grape', quantity: 15 }
18 * ]);
19 * const result = find(set, (value) => value.quantity > 10);
20 * // result will be: { name: 'grape', quantity: 15 }
21 */
22declare function find<T>(set: Set<T>, doesMatch: (value: T, value2: T, set: Set<T>) => boolean): T | undefined;
23
24export { find };
Note: See TracBrowser for help on using the repository browser.