|
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.2 KB
|
| Line | |
|---|
| 1 | import { ListIterateeCustom } from '../_internal/ListIterateeCustom.mjs';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T
|
|---|
| 7 | * @param {ArrayLike<T> | null | undefined} arr - The array to search through.
|
|---|
| 8 | * @param {((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | PropertyKey} doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.
|
|---|
| 9 | * @param {PropertyKey} propertyToCheck - The property name to check for in the items of the array.
|
|---|
| 10 | * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.
|
|---|
| 11 | * @returns {number} - The index of the first item that has the specified property, or `-1` if no match is found.
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * // Using a property name
|
|---|
| 15 | * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|---|
| 16 | * const result = findIndex(items, 'name');
|
|---|
| 17 | * console.log(result); // 0
|
|---|
| 18 | */
|
|---|
| 19 | declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatch?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
|
|---|
| 20 |
|
|---|
| 21 | export { findIndex };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.