|
1 | 1 | /* eslint-disable @typescript-eslint/method-signature-style */ |
2 | 2 |
|
| 3 | +import type { NonFalsy } from "./utils/non-falsy"; |
| 4 | +import type { WidenLiteral } from "./utils/widen-literal"; |
3 | 5 | import type * as Types from "@goodbyenjn/utils/types"; |
4 | 6 |
|
5 | 7 | declare global { |
@@ -50,6 +52,62 @@ declare global { |
50 | 52 | } |
51 | 53 | } |
52 | 54 |
|
| 55 | +declare global { |
| 56 | + interface Array<T> { |
| 57 | + /** |
| 58 | + * Returns the elements of an array that meet the condition specified in a callback function. |
| 59 | + * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. |
| 60 | + * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. |
| 61 | + */ |
| 62 | + filter<S extends T>(predicate: BooleanConstructor, thisArg?: any): NonFalsy<NoInfer<S>>[]; |
| 63 | + /** |
| 64 | + * Determines whether an array includes a certain element, returning true or false as appropriate. |
| 65 | + * @param searchElement The element to search for. |
| 66 | + * @param fromIndex The position in this array at which to begin searching for searchElement. |
| 67 | + */ |
| 68 | + includes(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): boolean; |
| 69 | + /** |
| 70 | + * Returns the index of the first occurrence of a value in an array, or -1 if it is not present. |
| 71 | + * @param searchElement The value to locate in the array. |
| 72 | + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. |
| 73 | + */ |
| 74 | + indexOf(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): number; |
| 75 | + /** |
| 76 | + * Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present. |
| 77 | + * @param searchElement The value to locate in the array. |
| 78 | + * @param fromIndex The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array. |
| 79 | + */ |
| 80 | + lastIndexOf(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): number; |
| 81 | + } |
| 82 | + |
| 83 | + interface ReadonlyArray<T> { |
| 84 | + /** |
| 85 | + * Returns the elements of an array that meet the condition specified in a callback function. |
| 86 | + * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. |
| 87 | + * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. |
| 88 | + */ |
| 89 | + filter<S extends T>(predicate: BooleanConstructor, thisArg?: any): NonFalsy<NoInfer<S>>[]; |
| 90 | + /** |
| 91 | + * Determines whether an array includes a certain element, returning true or false as appropriate. |
| 92 | + * @param searchElement The element to search for. |
| 93 | + * @param fromIndex The position in this array at which to begin searching for searchElement. |
| 94 | + */ |
| 95 | + includes(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): boolean; |
| 96 | + /** |
| 97 | + * Returns the index of the first occurrence of a value in an array. |
| 98 | + * @param searchElement The value to locate in the array. |
| 99 | + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. |
| 100 | + */ |
| 101 | + indexOf(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): number; |
| 102 | + /** |
| 103 | + * Returns the index of the last occurrence of a specified value in an array. |
| 104 | + * @param searchElement The value to locate in the array. |
| 105 | + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. |
| 106 | + */ |
| 107 | + lastIndexOf(searchElement: T | (WidenLiteral<T> & {}), fromIndex?: number): number; |
| 108 | + } |
| 109 | +} |
| 110 | + |
53 | 111 | declare global { |
54 | 112 | type AsyncFn<Return = any, Args extends readonly any[] = any[]> = Types.AsyncFn<Return, Args>; |
55 | 113 | type AsyncFnWithThis< |
|
0 commit comments