-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlib.es5.d.ts
768 lines (741 loc) · 32.1 KB
/
lib.es5.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
type First<T> = T extends [any] ? T[0] : unknown;
type UnionToIntersection<T> = (
T extends any ? (arg: T) => void : never
) extends (arg: infer F) => void
? F
: unknown;
type CheckNonNullable<T, U> = [T] extends [NonNullable<T>] ? U : never;
/**
* Evaluates JavaScript code and executes it.
* @param x A String value that contains valid JavaScript code.
*/
declare function eval(x: string): unknown;
interface Object {
/**
* Determines whether an object has a property with the specified name.
* @param v A property name.
*/
hasOwnProperty<Key extends PropertyKey>(
v: Key
): this is string extends Key
? {}
: number extends Key
? {}
: symbol extends Key
? {}
: Key extends PropertyKey
? { [key in Key]: unknown }
: {};
}
interface ObjectConstructor {
new (value?: any): Object;
(): {};
<T>(value: T): T extends object ? T : {};
/**
* Returns the prototype of an object.
* @param o The object that references the prototype.
*/
getPrototypeOf<T>(o: T): CheckNonNullable<T, unknown>;
/**
* Gets the own property descriptor of the specified object.
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
* @param o Object that contains the property.
* @param p Name of the property.
*/
getOwnPropertyDescriptor<T>(
o: T,
p: PropertyKey
): CheckNonNullable<T, PropertyDescriptor | undefined>;
/**
* Returns the names of the own properties of an object. The own properties of an object are those that are defined directly
* on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.
* @param o Object that contains the own properties.
*/
getOwnPropertyNames<T>(o: T): CheckNonNullable<T, string[]>;
/**
* Creates an object that has the specified prototype or that has null prototype.
* @param o Object to use as a prototype. May be null.
*/
create<O extends object>(o: O): O;
/**
* Creates an object that has the specified prototype or that has null prototype.
* @param o Object to use as a prototype. May be null.
*/
create(o: null): {};
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties.
* @param o Object to use as a prototype. May be null
* @param properties JavaScript object that contains one or more property descriptors.
*/
create<O extends object, P extends Record<PropertyKey, PropertyDescriptor>>(
o: O,
properties: P & ThisType<any>
): {
[K in keyof (O & P)]: P[K] extends { value: infer V }
? V
: P[K] extends { get: () => infer V }
? V
: K extends keyof O
? O[K]
: unknown;
};
/**
* Creates an object that has the specified prototype, and that optionally contains specified properties.
* @param o Object to use as a prototype. May be null
* @param properties JavaScript object that contains one or more property descriptors.
*/
create<P extends Record<string, PropertyDescriptor>>(
o: null,
properties: P & ThisType<any>
): {
[K in keyof P]: P[K] extends { value: infer V }
? V
: P[K] extends { get: () => infer V }
? V
: unknown;
};
/**
* Adds a property to an object, or modifies attributes of an existing property.
* @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.
* @param p The property name.
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
*/
defineProperty<
O extends object,
P extends PropertyKey,
D extends PropertyDescriptor
>(
o: O,
p: P,
attributes: D & ThisType<any>
): O &
(P extends PropertyKey // required to make P distributive
? {
[K in P]: D extends { value: infer V }
? V
: D extends { get: () => infer V }
? V
: unknown;
}
: unknown);
/**
* Adds one or more properties to an object, and/or modifies attributes of existing properties.
* @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
* @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.
*/
defineProperties<
O extends object,
P extends Record<PropertyKey, PropertyDescriptor>
>(
o: O,
properties: P & ThisType<any>
): {
[K in keyof (O & P)]: P[K] extends { value: infer V }
? V
: P[K] extends { get: () => infer V }
? V
: K extends keyof O
? O[K]
: unknown;
};
}
interface CallableFunction extends Function {
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<T, A extends readonly any[], B extends readonly any[], R>(
this: (this: T, ...args: [...A, ...B]) => R,
thisArg: T,
...args: A
): (...args: B) => R;
}
interface NewableFunction extends Function {
/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<A extends readonly any[], B extends readonly any[], R>(
this: new (...args: [...A, ...B]) => R,
thisArg: any,
...args: A
): new (...args: B) => R;
}
interface IArguments {
[index: number]: unknown;
}
interface String {
/**
* Replaces text in a string, using a regular expression or search string.
* @param searchValue A string or RegExp search value.
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
*/
replace(searchValue: string | RegExp, replaceValue: string): string;
/**
* Replaces text in a string, using a regular expression or search string.
* @param searchValue A string or RegExp search value.
* @param replacer A function that returns the replacement text.
*/
replace(
searchValue: string | RegExp,
replacer: (
substring: string,
// TODO: could be improved, but blocked by issue:
// https://github.com/microsoft/TypeScript/issues/45972
...rest: (string | number)[]
) => string
): string;
}
type JSONValue =
| null
| string
| number
| boolean
| {
[K in string]?: JSONValue;
}
| JSONValue[];
interface JSON {
/**
* Converts a JavaScript Object Notation (JSON) string into an object.
* @param text A valid JSON string.
* @param reviver A function that transforms the results. This function is called for each member of the object.
* If a member contains nested objects, the nested objects are transformed before the parent object is.
*/
parse(
text: string,
reviver?: (this: JSONValue, key: string, value: JSONValue) => any
): JSONValue;
/**
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
* @param value A JavaScript value, usually an object or array, to be converted.
* @param replacer A function that transforms the results.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
*/
stringify<T>(
value: T,
replacer?: (this: unknown, key: string, value: unknown) => any,
space?: string | number | null
): T extends unknown
? T extends
| undefined
| ((...args: any) => any)
| (new (...args: any) => any)
| symbol
? undefined
: object extends T
? string | undefined
: string
: never;
/**
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
* @param value A JavaScript value, usually an object or array, to be converted.
* @param replacer A function that transforms the results.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
*/
stringify(
value: unknown,
replacer?: (this: unknown, key: string, value: unknown) => any,
space?: string | number | null
): string | undefined;
/**
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
* @param value A JavaScript value, usually an object or array, to be converted.
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
*/
stringify<T>(
value: T,
replacer?: (number | string)[] | null,
space?: string | number | null
): T extends unknown
? T extends
| undefined
| ((...args: any) => any)
| (new (...args: any) => any)
| symbol
? undefined
: object extends T
? string | undefined
: string
: never;
/**
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
* @param value A JavaScript value, usually an object or array, to be converted.
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
*/
stringify(
value: unknown,
replacer?: (number | string)[] | null,
space?: string | number | null
): string | undefined;
}
interface ReadonlyArray<T> {
/**
* Determines whether all the members of an array satisfy the specified test.
* @param predicate A function that accepts up to three arguments. The every method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value false, or until the end of the array.
* @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.
*/
every<S extends T, This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => value is S,
thisArg?: This
): this is { [K in keyof this]: S };
/**
* Determines whether all the members of an array satisfy the specified test.
* @param predicate A function that accepts up to three arguments. The every method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value false, or until the end of the array.
* @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.
*/
every<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): boolean;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param predicate A function that accepts up to three arguments. The some method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value true, or until the end of the array.
* @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.
*/
some<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): boolean;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach<This = undefined>(
callbackfn: (this: This, value: T, index: number, array: this) => void,
thisArg?: This
): void;
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
map<U, This = undefined>(
callbackfn: (this: This, value: T, index: number, array: this) => U,
thisArg?: This
): { -readonly [K in keyof this]: U };
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @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.
* @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.
*/
filter<S extends T, This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => value is S,
thisArg?: This
): S[];
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @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.
* @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.
*/
filter<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): T[];
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
*/
reduce<U = T>(
callbackfn: (
previousValue: T | U,
currentValue: T,
currentIndex: number,
array: this
) => U
): T | U;
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduce<U = T>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
*/
reduceRight<U = T>(
callbackfn: (
previousValue: T | U,
currentValue: T,
currentIndex: number,
array: this
) => U
): T | U;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduceRight<U = T>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
}
interface Array<T> {
/**
* Determines whether all the members of an array satisfy the specified test.
* @param predicate A function that accepts up to three arguments. The every method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value false, or until the end of the array.
* @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.
*/
every<S extends T, This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => value is S,
thisArg?: This
): this is { [K in keyof this]: S };
/**
* Determines whether all the members of an array satisfy the specified test.
* @param predicate A function that accepts up to three arguments. The every method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value false, or until the end of the array.
* @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.
*/
every<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): boolean;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param predicate A function that accepts up to three arguments. The some method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value true, or until the end of the array.
* @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.
*/
some<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): boolean;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach<This = undefined>(
callbackfn: (this: This, value: T, index: number, array: this) => void,
thisArg?: This
): void;
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
map<U, This = undefined>(
callbackfn: (this: This, value: T, index: number, array: this) => U,
thisArg?: This
): { [K in keyof this]: U };
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @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.
* @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.
*/
filter<S extends T, This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => value is S,
thisArg?: This
): S[];
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @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.
* @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.
*/
filter<This = undefined>(
predicate: (this: This, value: T, index: number, array: this) => boolean,
thisArg?: This
): T[];
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
*/
reduce<U = T>(
callbackfn: (
previousValue: T | U,
currentValue: T,
currentIndex: number,
array: this
) => U
): T | U;
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduce<U = T>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
*/
reduceRight<U = T>(
callbackfn: (
previousValue: T | U,
currentValue: T,
currentIndex: number,
array: this
) => U
): T | U;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduceRight<U = T>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
}
interface ArrayConstructor {
new <T>(arrayLength: number): T[];
new <T>(...items: T[]): T[];
<T>(arrayLength: number): T[];
<T>(...items: T[]): T[];
isArray(arg: any): arg is unknown[];
readonly prototype: unknown[];
}
declare type PromiseConstructorLike = new <T>(
executor: (
resolve: undefined extends T
? {
(value?: T | PromiseLike<T>): void;
}
: {
(value: T | PromiseLike<T>): void;
},
reject: (reason?: any) => void
) => void
) => PromiseLike<T>;
interface TypedNumberArray {
/**
* Determines whether all the members of an array satisfy the specified test.
* @param predicate A function that accepts up to three arguments. The every method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value false, or until the end of the array.
* @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.
*/
every<This = undefined>(
predicate: (
this: This,
value: number,
index: number,
array: this
) => boolean,
thisArg?: This
): boolean;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @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.
* @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.
*/
filter<This = undefined>(
predicate: (
this: This,
value: number,
index: number,
array: this
) => boolean,
thisArg?: This
): TypedNumberArray;
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find<This = undefined>(
predicate: (this: This, value: number, index: number, obj: this) => boolean,
thisArg?: This
): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex<This = undefined>(
predicate: (this: This, value: number, index: number, obj: this) => boolean,
thisArg?: This
): number;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
forEach<This = undefined>(
callbackfn: (this: This, value: number, index: number, array: this) => void,
thisArg?: This
): void;
/**
* Calls a defined callback function on each element of an array, and returns an array that
* contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
map<This = undefined>(
callbackfn: (
this: This,
value: number,
index: number,
array: this
) => number,
thisArg?: This
): TypedNumberArray;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
*/
reduce<U = number>(
callbackfn: (
previousValue: number | U,
currentValue: number,
currentIndex: number,
array: this
) => U
): number | U;
/**
* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduce<U = number>(
callbackfn: (
previousValue: U,
currentValue: number,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
*/
reduceRight<U = number>(
callbackfn: (
previousValue: number | U,
currentValue: number,
currentIndex: number,
array: this
) => U
): number | U;
/**
* Calls the specified callback function for all the elements in an array, in descending order.
* The return value of the callback function is the accumulated result, and is provided as an
* argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
* the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.
*/
reduceRight<U = number>(
callbackfn: (
previousValue: U,
currentValue: number,
currentIndex: number,
array: this
) => U,
initialValue: U
): U;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param predicate A function that accepts up to three arguments. The some method calls
* the predicate function for each element in the array until the predicate returns a value
* which is coercible to the Boolean value true, or until the end of the array.
* @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.
*/
some<This = undefined>(
predicate: (
this: This,
value: number,
index: number,
array: this
) => boolean,
thisArg?: This
): boolean;
}
interface TypedNumberArrayConstructor {
/**
* Creates an array from an array-like or iterable object.
* @param source An array-like or iterable object to convert to an array.
*/
from(source: ArrayLike<number>): TypedNumberArray;
/**
* Creates an array from an array-like or iterable object.
* @param source An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, This = undefined>(
source: ArrayLike<T>,
mapfn: (this: This, v: T, k: number) => number,
thisArg?: This
): TypedNumberArray;
}