source: node_modules/es-toolkit/dist/object/findKey.d.mts

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

Added visualizations

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[a762898]1/**
2 * Finds the key of the first element in the object that satisfies the provided testing function.
3 *
4 * @param {T} obj - The object to search.
5 * @param {(value: T[keyof T], key: keyof T, obj: T) => boolean} predicate - The function to execute on each value in the object. It takes three arguments:
6 * - value: The current value being processed in the object.
7 * - key: The key of the current value being processed in the object.
8 * - obj: The object that findKey was called upon.
9 * @returns {keyof T | undefined} The key of the first element in the object that passes the test, or undefined if no element passes.
10 *
11 * @example
12 * const users = {
13 * 'barney': { 'age': 36, 'active': true },
14 * 'fred': { 'age': 40, 'active': false },
15 * 'pebbles': { 'age': 1, 'active': true }
16 * };
17 * findKey(users, function(o) { return o.age < 40; }); => 'barney'
18 */
19declare function findKey<T extends Record<any, any>>(obj: T, predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined;
20
21export { findKey };
Note: See TracBrowser for help on using the repository browser.