-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcore.js
3009 lines (2878 loc) · 140 KB
/
core.js
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Modifications Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.apache.org/licenses/LICENSE-2.0
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
* MERCHANTABLITY OR NON-INFRINGEMENT.
* See the Apache Version 2.0 License for specific language governing permissions
* and limitations under the License.
*
* @flow
*/
// @lint-ignore-every LICENSELINT
declare var NaN: number;
declare var Infinity: number;
declare var undefined: void;
/**
* Converts a string to an integer.
* @param string A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
declare function parseInt(string: mixed, radix?: number): number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
declare function parseFloat(string: mixed): number;
/**
* Returns a boolean value that indicates whether a value is the reserved value NaN (not a number).
* @param number A numeric value.
*/
declare function isNaN(number: mixed): boolean;
/**
* Determines whether a supplied number is finite.
* @param number Any numeric value.
*/
declare function isFinite(number: mixed): boolean;
/**
* Gets the unencoded version of an encoded Uniform Resource Identifier (URI).
* @param encodedURI A value representing an encoded URI.
*/
declare function decodeURI(encodedURI: string): string;
/**
* Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).
* @param encodedURIComponent A value representing an encoded URI component.
*/
declare function decodeURIComponent(encodedURIComponent: string): string;
/**
* Encodes a text string as a valid Uniform Resource Identifier (URI)
* @param uri A value representing an encoded URI.
*/
declare function encodeURI(uri: string): string;
/**
* Encodes a text string as a valid component of a Uniform Resource Identifier (URI).
* @param uriComponent A value representing an encoded URI component.
*/
declare function encodeURIComponent(uriComponent: string): string;
type PropertyDescriptor<T> = {
enumerable?: boolean,
configurable?: boolean,
writable?: boolean,
value?: T,
get?: () => T,
set?: (value: T) => void,
...
};
type PropertyDescriptorMap = { [s: string]: PropertyDescriptor<any>, ... }
type $NotNullOrVoid =
| number
| string
| boolean
| interface {}
| $ReadOnlyArray<mixed>
| symbol
| bigint
| EnumValue<>
| Enum<>;
declare class Object {
static (o: ?void): { [key: any]: any, ... };
static (o: boolean): Boolean;
static (o: number): Number;
static (o: string): String;
static <T>(o: T): T;
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources The source object from which to copy properties.
*/
static assign: Object$Assign;
/**
* 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.
*/
static create(o: any, properties?: PropertyDescriptorMap): any; // compiler magic
/**
* 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.
*/
static defineProperties(o: any, properties: PropertyDescriptorMap): any;
/**
* 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.
*/
static defineProperty<T>(o: any, p: any, attributes: PropertyDescriptor<T>): any;
/**
* Returns an array of key/values of the enumerable properties of an object
* @param object Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
static entries(object: interface {}): Array<[string, mixed]>;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
static freeze<T>(o: T): T;
/**
* Returns an object created by key-value entries for properties and methods
* @param entries An iterable object that contains key-value entries for properties and methods.
*/
static fromEntries<K, V>(entries: Iterable<[K, V] | {
'0': K,
'1': V,
...
}>): { [K]: V, ... };
/**
* 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.
*/
static getOwnPropertyDescriptor<T = mixed>(o: $NotNullOrVoid, p: any): PropertyDescriptor<T> | void;
/**
* Gets the own property descriptors 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 properties.
*/
static getOwnPropertyDescriptors(o: {...}): PropertyDescriptorMap;
// This is documentation only. Object.getOwnPropertyNames is implemented in OCaml code
// https://github.com/facebook/flow/blob/8ac01bc604a6827e6ee9a71b197bb974f8080049/src/typing/statement.ml#L6308
/**
* 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.
*/
static getOwnPropertyNames(o: $NotNullOrVoid): Array<string>;
/**
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
static getOwnPropertySymbols(o: $NotNullOrVoid): Array<symbol>;
/**
* Returns the prototype of an object.
* @param o The object that references the prototype.
*/
static getPrototypeOf(o: $NotNullOrVoid): any;
/**
* Returns true if the specified object has the indicated property as its own property.
* If the property is inherited, or does not exist, the method returns false.
* @param obj The JavaScript object instance to test.
* @param prop The String name or Symbol of the property to test.
*/
static hasOwn(obj: $NotNullOrVoid, prop: mixed): boolean;
/**
* Returns true if the values are the same value, false otherwise.
* @param a The first value.
* @param b The second value.
*/
static is<T>(a: T, b: T): boolean;
/**
* Returns a value that indicates whether new properties can be added to an object.
* @param o Object to test.
*/
static isExtensible(o: $NotNullOrVoid): boolean;
/**
* Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object.
* @param o Object to test.
*/
static isFrozen(o: $NotNullOrVoid): boolean;
static isSealed(o: $NotNullOrVoid): boolean;
// This is documentation only. Object.keys is implemented in OCaml code.
// https://github.com/facebook/flow/blob/8ac01bc604a6827e6ee9a71b197bb974f8080049/src/typing/statement.ml#L6308
/**
* Returns the names of the enumerable string properties and methods of an object.
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
static keys(o: interface {}): Array<string>;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
static preventExtensions<T>(o: T): T;
/**
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
static seal<T>(o: T): T;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
*/
static setPrototypeOf<T>(o: T, proto: ?{...}): T;
/**
* Returns an array of values of the enumerable properties of an object
* @param object Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
static values(object: interface {}): Array<mixed>;
/**
* Determines whether an object has a property with the specified name.
* @param prop A property name.
*/
hasOwnProperty(prop: mixed): boolean;
/**
* Determines whether an object exists in another object's prototype chain.
* @param o Another object whose prototype chain is to be checked.
*/
isPrototypeOf(o: mixed): boolean;
/**
* Determines whether a specified property is enumerable.
* @param prop A property name.
*/
propertyIsEnumerable(prop: mixed): boolean;
/** Returns a date converted to a string using the current locale. */
toLocaleString(): string;
/** Returns a string representation of an object. */
toString(): string;
/** Returns the primitive value of the specified object. */
valueOf(): mixed;
}
// Well known Symbols.
declare opaque type $SymbolHasInstance: symbol;
declare opaque type $SymboIsConcatSpreadable: symbol;
declare opaque type $SymbolIterator: symbol;
declare opaque type $SymbolMatch: symbol;
declare opaque type $SymbolMatchAll: symbol;
declare opaque type $SymbolReplace: symbol;
declare opaque type $SymbolSearch: symbol;
declare opaque type $SymbolSpecies: symbol;
declare opaque type $SymbolSplit: symbol;
declare opaque type $SymbolToPrimitive: symbol;
declare opaque type $SymbolToStringTag: symbol;
declare opaque type $SymbolUnscopables: symbol;
declare class Symbol {
/**
* Returns a new unique Symbol value.
* @param value Description of the new Symbol object.
*/
static (value?: mixed): symbol;
/**
* A method that returns the default async iterator for an object. Called by the semantics of
* the for-await-of statement.
*/
static +asyncIterator: '@@asyncIterator'; // polyfill '@@asyncIterator'
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
static for(key: string): symbol;
/**
* Expose the [[Description]] internal slot of a symbol directly.
*/
+description: string | void;
/**
* A method that determines if a constructor object recognizes an object as one of the
* constructor's instances. Called by the semantics of the instanceof operator.
*/
static +hasInstance: $SymbolHasInstance;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
static +isConcatSpreadable: $SymboIsConcatSpreadable;
/**
* A method that returns the default iterator for an object. Called by the semantics of the
* for-of statement.
*/
static +iterator: '@@iterator'; // polyfill '@@iterator'
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
static keyFor(sym: symbol): ?string;
static +length: 0;
/**
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.match method.
*/
static +match: $SymbolMatch;
/**
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.matchAll method.
*/
static +matchAll: $SymbolMatchAll;
/**
* A regular expression method that replaces matched substrings of a string. Called by the
* String.prototype.replace method.
*/
static +replace: $SymbolReplace;
/**
* A regular expression method that returns the index within a string that matches the
* regular expression. Called by the String.prototype.search method.
*/
static +search: $SymbolSearch;
/**
* A function valued property that is the constructor function that is used to create
* derived objects.
*/
static +species: $SymbolSpecies;
/**
* A regular expression method that splits a string at the indices that match the regular
* expression. Called by the String.prototype.split method.
*/
static +split: $SymbolSplit;
/**
* A method that converts an object to a corresponding primitive value.
* Called by the ToPrimitive abstract operation.
*/
static +toPrimitive: $SymbolToPrimitive;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
static +toStringTag: $SymbolToStringTag;
/**
* An Object whose own property names are property names that are excluded from the 'with'
* environment bindings of the associated objects.
*/
static +unscopables: $SymbolUnscopables;
toString(): string;
valueOf(): ?symbol;
}
// TODO: instance, static
declare class Function {
proto apply: (<T, R, A: $ArrayLike<mixed> = []>(this: (this: T, ...args: A) => R, thisArg: T, args?: A) => R);
proto bind: Function$Prototype$Bind; // (thisArg: any, ...argArray: Array<any>) => any;
proto call: <T, R, A: $ArrayLike<mixed> = []>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A) => R;
/** Returns a string representation of a function. */
toString(): string;
arguments: any;
caller: any | null;
+length: number;
/**
* Returns the name of the function.
*/
+name: string;
}
declare class Boolean {
constructor(value?: mixed): void;
static (value:mixed):boolean;
/** Returns the primitive value of the specified object. */
valueOf(): boolean;
toString(): string;
}
/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */
declare class Number {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 10^-16.
*/
static EPSILON: number;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 - 1.
*/
static MAX_SAFE_INTEGER: number;
/** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */
static MAX_VALUE: number;
/**
* The value of the smallest integer n such that n and n - 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(2^53 - 1)).
*/
static MIN_SAFE_INTEGER: number;
/** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */
static MIN_VALUE: number;
/**
* A value that is not a number.
* In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function.
*/
static NaN: number;
/**
* A value that is less than the largest negative number that can be represented in JavaScript.
* JavaScript displays NEGATIVE_INFINITY values as -infinity.
*/
static NEGATIVE_INFINITY: number;
/**
* A value greater than the largest number that can be represented in JavaScript.
* JavaScript displays POSITIVE_INFINITY values as infinity.
*/
static POSITIVE_INFINITY: number;
static (value:mixed):number;
/**
* Returns true if passed value is finite.
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param value A numeric value.
*/
static isFinite(value: mixed): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param value A numeric value.
*/
static isInteger(value: mixed): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param value A numeric value.
*/
static isNaN(value: mixed): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param value A numeric value.
*/
static isSafeInteger(value: mixed): boolean;
/**
* Converts a string to a floating-point number.
* @param value A string that contains a floating-point number.
*/
static parseFloat(value: string): number;
/**
* Converts A string to an integer.
* @param value A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
static parseInt(value: string, radix?: number): number;
constructor(value?: mixed): void;
/**
* Returns a string containing a number represented in exponential notation.
* @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
*/
toExponential(fractionDigits?: number): string;
/**
* Returns a string representing a number in fixed-point notation.
* @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
*/
toFixed(fractionDigits?: number): string;
/**
* Converts a number to a string by using the current or specified locale.
* @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string | Array<string>, options?: Intl$NumberFormatOptions): string;
/**
* Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/**
* Returns a string representation of an object.
* @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers.
*/
toString(radix?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
/** An intrinsic object that provides basic mathematics functionality and constants. */
declare var Math: {
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
E: number,
/** The natural logarithm of 10. */
LN10: number,
/** The natural logarithm of 2. */
LN2: number,
/** The base-10 logarithm of e. */
LOG10E: number,
/** The base-2 logarithm of e. */
LOG2E: number,
/** Pi. This is the ratio of the circumference of a circle to its diameter. */
PI: number,
/** The square root of 0.5, or, equivalently, one divided by the square root of 2. */
SQRT1_2: number,
/** The square root of 2. */
SQRT2: number,
/**
* Returns the absolute value of a number (the value without regard to whether it is positive or negative).
* For example, the absolute value of -5 is the same as the absolute value of 5.
* @param x A numeric expression for which the absolute value is needed.
*/
abs(x: number): number,
/**
* Returns the arc cosine (or inverse cosine) of a number.
* @param x A numeric expression.
*/
acos(x: number): number,
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number,
/**
* Returns the arcsine of a number.
* @param x A numeric expression.
*/
asin(x: number): number,
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number,
/**
* Returns the arctangent of a number.
* @param x A numeric expression for which the arctangent is needed.
*/
atan(x: number): number,
/**
* Returns the angle (in radians) from the X axis to a point.
* @param y A numeric expression representing the cartesian y-coordinate.
* @param x A numeric expression representing the cartesian x-coordinate.
*/
atan2(y: number, x: number): number,
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number,
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number,
/**
* Returns the smallest integer greater than or equal to its numeric argument.
* @param x A numeric expression.
*/
ceil(x: number): number,
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number,
/**
* Returns the cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cos(x: number): number,
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number,
/**
* Returns e (the base of natural logarithms) raised to a power.
* @param x A numeric expression representing the power of e.
*/
exp(x: number): number,
/**
* Returns the result of (e^x - 1), which is an implementation-dependent approximation to
* subtracting 1 from the exponential function of x (e raised to the power of x, where e
* is the base of the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number,
/**
* Returns the greatest integer less than or equal to its numeric argument.
* @param x A numeric expression.
*/
floor(x: number): number,
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number,
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or -0, the result is +0.
*/
hypot(...values: Array<number>): number,
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number,
/**
* Returns the natural logarithm (base e) of a number.
* @param x A numeric expression.
*/
log(x: number): number,
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number,
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number,
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number,
/**
* Returns the larger of a set of supplied numeric expressions.
* @param values Numeric expressions to be evaluated.
*/
max(...values: Array<number>): number,
/**
* Returns the smaller of a set of supplied numeric expressions.
* @param values Numeric expressions to be evaluated.
*/
min(...values: Array<number>): number,
/**
* Returns the value of a base expression taken to a specified power.
* @param x The base value of the expression.
* @param y The exponent value of the expression.
*/
pow(x: number, y: number): number,
/** Returns a pseudorandom number between 0 and 1. */
random(): number,
/**
* Returns a supplied numeric expression rounded to the nearest integer.
* @param x The value to be rounded to the nearest integer.
*/
round(x: number): number,
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number,
/**
* Returns the sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sin(x: number): number,
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number,
/**
* Returns the square root of a number.
* @param x A numeric expression.
*/
sqrt(x: number): number,
/**
* Returns the tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tan(x: number): number,
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number,
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number,
...
};
/**
* A class of Array methods and properties that don't mutate the array.
*/
declare class $ReadOnlyArray<+T> {
@@iterator(): Iterator<T>;
/**
* Returns a string representation of an array. The elements are converted to string using their toLocalString methods.
*/
toLocaleString(): string;
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired item. A negative index will count back from the last item.
*/
at(index: number): T | void;
// concat creates a new array
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat<S = T>(...items: Array<$ReadOnlyArray<S> | S>): Array<T | S>;
/**
* Returns an iterable of key, value pairs for every entry in the array
*/
entries(): Iterator<[number, T]>;
/**
* Determines whether all the members of an array satisfy the specified test.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): boolean;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
*/
filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A predicate 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.
* @returns An array whose type is specified by the predicate function passed as callbackfn.
*/
filter<This, S: T>(callbackfn: (this: This, value: T, index: number, array: $ReadOnlyArray<T>) => implies value is S, thisArg: This): Array<S>;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg : This): Array<T>;
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): T | void;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): number;
/**
* Returns the value of the last element in the array where predicate is true, and undefined
* otherwise.
* @param callbackfn find calls predicate once for each element of the array, in reverse
* 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.
*/
findLast<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): T | void;
/**
* Returns the index of the last element in the array where predicate is true, and -1
* otherwise.
* @param callbackfn find calls predicate once for each element of the array, in reverse
* order, until it finds one where predicate returns true. If such an element is found,
* findLastIndex immediately returns that element index. Otherwise, findLastIndex 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.
*/
findLastIndex<This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: mixed, fromIndex?: number): boolean;
/**
* Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
indexOf(searchElement: mixed, fromIndex?: number): number;
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
*/
join(separator?: string): string;
/**
* Returns an iterable of keys in the array
*/
keys(): Iterator<number>;
/**
* Returns the index of the last occurrence of a specified value in an array.
* @param searchElement The value to locate in the array.
* @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.
*/
lastIndexOf(searchElement: mixed, fromIndex?: number): number;
/**
* 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => U, thisArg: This): Array<U>;
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callbackfn A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U, This>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => $ReadOnlyArray<U> | U, thisArg: This): Array<U>;
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat(depth: 0): Array<T>;
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat(depth: void | 1): Array<T extends $ReadOnlyArray<infer E> ? E : T>;
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat(depth: number): Array<mixed>;
/**
* 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(
callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => T,
): 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.
* @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>(
callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => 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(
callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => T,
): T;
/**
* 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>(
callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: $ReadOnlyArray<T>) => U,
initialValue: U
): U;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
*/
slice(start?: number, end?: number): Array<T>;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: $ReadOnlyArray<T>) => mixed, thisArg: This): boolean;
/**
* Returns a new array with the elements in reversed order.
* It is the copying counterpart of the reverse() method.
*/
toReversed(): Array<T>;
/**
* Returns a new array with the elements sorted in ascending order.
* It is the copying counterpart of the sort() method.
* @param compareFn Specifies a function that defines the sort order.
* If omitted, the array elements are converted to strings, then sorted according
* to each character's Unicode code point value.
*/
toSorted(compareFn?: (a: T, b: T) => number): Array<T>;
/**
* Returns a new array with some elements removed and/or replaced at a given index.
* It is the copying counterpart of the splice() method.
* @param start Zero-based index at which to start changing the array, converted to an integer.
* @param deleteCount An integer indicating the number of elements in the array to remove from start.
* @param items The elements to add to the array, beginning from start.
*/
toSpliced<S>(start: number, deleteCount?: number, ...items: Array<S>): Array<T | S>;
/**
* Returns an iterable of values in the array
*/
values(): Iterator<T>;
/**
* Returns a new array with the element at the given index replaced with the given value.
* It is the copying version of using the bracket notation to change the value of a given index.
* @param index Zero-based index at which to change the array, converted to an integer.
* @param value Any value to be assigned to the given index.
*/
with(index: number, value: T): Array<T>;
+[key: number]: T;
/**
* Gets the length of the array. This is a number one higher than the highest element defined in an array.
*/
+length: number;
}
declare class Array<T> extends $ReadOnlyArray<T> {
/**
* Returns a new JavaScript array with its length property set to that number.
* (Note: this implies an array of arrayLength empty slots, not slots with actual undefined
* values. See [sparse arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays)).
*/
constructor(arrayLength?: number): void;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): T[];
/**
* Determines whether all the members of an array satisfy the specified test.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: Array<T>) => mixed, thisArg: This): boolean;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param begin index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, begin?: number, end?: number): Array<T>;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
*/
filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A predicate 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.
* @returns An array whose type is specified by the predicate function passed as callbackfn.
*/
filter<This, S: T>(callbackfn: (this: This, value: T, index: number, array: $ReadOnlyArray<T>) => implies value is S, thisArg: This): Array<S>;
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn 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>(callbackfn: (this : This, value: T, index: number, array: Array<T>) => mixed, thisArg: This): Array<T>;
/**
* Returns the value of the first element in the array where predicate is true, and undefined