Skip to content

Commit 5f665ad

Browse files
authored
Merge pull request #9996 from joshaber/patch-1
Add `find` and `findIndex` to ReadonlyArray
2 parents 269b828 + 34e78e6 commit 5f665ad

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/lib/es2015.core.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,30 @@ interface ObjectConstructor {
343343
defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
344344
}
345345

346+
interface ReadonlyArray<T> {
347+
/**
348+
* Returns the value of the first element in the array where predicate is true, and undefined
349+
* otherwise.
350+
* @param predicate find calls predicate once for each element of the array, in ascending
351+
* order, until it finds one where predicate returns true. If such an element is found, find
352+
* immediately returns that element value. Otherwise, find returns undefined.
353+
* @param thisArg If provided, it will be used as the this value for each invocation of
354+
* predicate. If it is not provided, undefined is used instead.
355+
*/
356+
find(predicate: (value: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): T | undefined;
357+
358+
/**
359+
* Returns the index of the first element in the array where predicate is true, and undefined
360+
* otherwise.
361+
* @param predicate find calls predicate once for each element of the array, in ascending
362+
* order, until it finds one where predicate returns true. If such an element is found,
363+
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
364+
* @param thisArg If provided, it will be used as the this value for each invocation of
365+
* predicate. If it is not provided, undefined is used instead.
366+
*/
367+
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
368+
}
369+
346370
interface RegExp {
347371
/**
348372
* Returns a string indicating the flags of the regular expression in question. This field is read-only.

0 commit comments

Comments
 (0)