1/*! *****************************************************************************
2Copyright (c) Microsoft Corporation. All rights reserved.
3Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4this file except in compliance with the License. You may obtain a copy of the
5License at http://www.apache.org/licenses/LICENSE-2.0
6
7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10MERCHANTABLITY OR NON-INFRINGEMENT.
11
12See the Apache Version 2.0 License for specific language governing permissions
13and limitations under the License.
14***************************************************************************** */
15
16
17
18/// <reference no-default-lib="true"/>
19
20
21interface Array<T> {
22    /**
23     * Returns the value of the first element in the array where predicate is true, and undefined
24     * otherwise.
25     * @param predicate find calls predicate once for each element of the array, in ascending
26     * order, until it finds one where predicate returns true. If such an element is found, find
27     * immediately returns that element value. Otherwise, find returns undefined.
28     * @param thisArg If provided, it will be used as the this value for each invocation of
29     * predicate. If it is not provided, undefined is used instead.
30     */
31    find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
32    find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
33
34    /**
35     * Returns the index of the first element in the array where predicate is true, and -1
36     * otherwise.
37     * @param predicate find calls predicate once for each element of the array, in ascending
38     * order, until it finds one where predicate returns true. If such an element is found,
39     * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
40     * @param thisArg If provided, it will be used as the this value for each invocation of
41     * predicate. If it is not provided, undefined is used instead.
42     */
43    findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
44
45    /**
46     * Returns the this object after filling the section identified by start and end with value
47     * @param value value to fill array section with
48     * @param start index to start filling the array at. If start is negative, it is treated as
49     * length+start where length is the length of the array.
50     * @param end index to stop filling the array at. If end is negative, it is treated as
51     * length+end.
52     */
53    fill(value: T, start?: number, end?: number): this;
54
55    /**
56     * Returns the this object after copying a section of the array identified by start and end
57     * to the same array starting at position target
58     * @param target If target is negative, it is treated as length+target where length is the
59     * length of the array.
60     * @param start If start is negative, it is treated as length+start. If end is negative, it
61     * is treated as length+end.
62     * @param end If not specified, length of the this object is used as its default value.
63     */
64    copyWithin(target: number, start: number, end?: number): this;
65}
66
67interface ArrayConstructor {
68    /**
69     * Creates an array from an array-like object.
70     * @param arrayLike An array-like object to convert to an array.
71     */
72    from<T>(arrayLike: ArrayLike<T>): T[];
73
74    /**
75     * Creates an array from an iterable object.
76     * @param arrayLike An array-like object to convert to an array.
77     * @param mapfn A mapping function to call on every element of the array.
78     * @param thisArg Value of 'this' used to invoke the mapfn.
79     */
80    from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
81
82    /**
83     * Returns a new array from a set of elements.
84     * @param items A set of elements to include in the new array object.
85     */
86    of<T>(...items: T[]): T[];
87}
88
89interface DateConstructor {
90    new (value: number | string | Date): Date;
91}
92
93interface Function {
94    /**
95     * Returns the name of the function. Function names are read-only and can not be changed.
96     */
97    readonly name: string;
98}
99
100interface Math {
101    /**
102     * Returns the number of leading zero bits in the 32-bit binary representation of a number.
103     * @param x A numeric expression.
104     */
105    clz32(x: number): number;
106
107    /**
108     * Returns the result of 32-bit multiplication of two numbers.
109     * @param x First number
110     * @param y Second number
111     */
112    imul(x: number, y: number): number;
113
114    /**
115     * Returns the sign of the x, indicating whether x is positive, negative or zero.
116     * @param x The numeric expression to test
117     */
118    sign(x: number): number;
119
120    /**
121     * Returns the base 10 logarithm of a number.
122     * @param x A numeric expression.
123     */
124    log10(x: number): number;
125
126    /**
127     * Returns the base 2 logarithm of a number.
128     * @param x A numeric expression.
129     */
130    log2(x: number): number;
131
132    /**
133     * Returns the natural logarithm of 1 + x.
134     * @param x A numeric expression.
135     */
136    log1p(x: number): number;
137
138    /**
139     * Returns the result of (e^x - 1), which is an implementation-dependent approximation to
140     * subtracting 1 from the exponential function of x (e raised to the power of x, where e
141     * is the base of the natural logarithms).
142     * @param x A numeric expression.
143     */
144    expm1(x: number): number;
145
146    /**
147     * Returns the hyperbolic cosine of a number.
148     * @param x A numeric expression that contains an angle measured in radians.
149     */
150    cosh(x: number): number;
151
152    /**
153     * Returns the hyperbolic sine of a number.
154     * @param x A numeric expression that contains an angle measured in radians.
155     */
156    sinh(x: number): number;
157
158    /**
159     * Returns the hyperbolic tangent of a number.
160     * @param x A numeric expression that contains an angle measured in radians.
161     */
162    tanh(x: number): number;
163
164    /**
165     * Returns the inverse hyperbolic cosine of a number.
166     * @param x A numeric expression that contains an angle measured in radians.
167     */
168    acosh(x: number): number;
169
170    /**
171     * Returns the inverse hyperbolic sine of a number.
172     * @param x A numeric expression that contains an angle measured in radians.
173     */
174    asinh(x: number): number;
175
176    /**
177     * Returns the inverse hyperbolic tangent of a number.
178     * @param x A numeric expression that contains an angle measured in radians.
179     */
180    atanh(x: number): number;
181
182    /**
183     * Returns the square root of the sum of squares of its arguments.
184     * @param values Values to compute the square root for.
185     *     If no arguments are passed, the result is +0.
186     *     If there is only one argument, the result is the absolute value.
187     *     If any argument is +Infinity or -Infinity, the result is +Infinity.
188     *     If any argument is NaN, the result is NaN.
189     *     If all arguments are either +0 or −0, the result is +0.
190     */
191    hypot(...values: number[]): number;
192
193    /**
194     * Returns the integral part of the a numeric expression, x, removing any fractional digits.
195     * If x is already an integer, the result is x.
196     * @param x A numeric expression.
197     */
198    trunc(x: number): number;
199
200    /**
201     * Returns the nearest single precision float representation of a number.
202     * @param x A numeric expression.
203     */
204    fround(x: number): number;
205
206    /**
207     * Returns an implementation-dependent approximation to the cube root of number.
208     * @param x A numeric expression.
209     */
210    cbrt(x: number): number;
211}
212
213interface NumberConstructor {
214    /**
215     * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
216     * that is representable as a Number value, which is approximately:
217     * 2.2204460492503130808472633361816 x 10‍−‍16.
218     */
219    readonly EPSILON: number;
220
221    /**
222     * Returns true if passed value is finite.
223     * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
224     * number. Only finite values of the type number, result in true.
225     * @param number A numeric value.
226     */
227    isFinite(number: number): boolean;
228
229    /**
230     * Returns true if the value passed is an integer, false otherwise.
231     * @param number A numeric value.
232     */
233    isInteger(number: number): boolean;
234
235    /**
236     * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
237     * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
238     * to a number. Only values of the type number, that are also NaN, result in true.
239     * @param number A numeric value.
240     */
241    isNaN(number: number): boolean;
242
243    /**
244     * Returns true if the value passed is a safe integer.
245     * @param number A numeric value.
246     */
247    isSafeInteger(number: number): boolean;
248
249    /**
250     * The value of the largest integer n such that n and n + 1 are both exactly representable as
251     * a Number value.
252     * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
253     */
254    readonly MAX_SAFE_INTEGER: number;
255
256    /**
257     * The value of the smallest integer n such that n and n − 1 are both exactly representable as
258     * a Number value.
259     * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
260     */
261    readonly MIN_SAFE_INTEGER: number;
262
263    /**
264     * Converts a string to a floating-point number.
265     * @param string A string that contains a floating-point number.
266     */
267    parseFloat(string: string): number;
268
269    /**
270     * Converts A string to an integer.
271     * @param s A string to convert into a number.
272     * @param radix A value between 2 and 36 that specifies the base of the number in numString.
273     * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
274     * All other strings are considered decimal.
275     */
276    parseInt(string: string, radix?: number): number;
277}
278
279interface ObjectConstructor {
280    /**
281     * Copy the values of all of the enumerable own properties from one or more source objects to a
282     * target object. Returns the target object.
283     * @param target The target object to copy to.
284     * @param source The source object from which to copy properties.
285     */
286    assign<T, U>(target: T, source: U): T & U;
287
288    /**
289     * Copy the values of all of the enumerable own properties from one or more source objects to a
290     * target object. Returns the target object.
291     * @param target The target object to copy to.
292     * @param source1 The first source object from which to copy properties.
293     * @param source2 The second source object from which to copy properties.
294     */
295    assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
296
297    /**
298     * Copy the values of all of the enumerable own properties from one or more source objects to a
299     * target object. Returns the target object.
300     * @param target The target object to copy to.
301     * @param source1 The first source object from which to copy properties.
302     * @param source2 The second source object from which to copy properties.
303     * @param source3 The third source object from which to copy properties.
304     */
305    assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
306
307    /**
308     * Copy the values of all of the enumerable own properties from one or more source objects to a
309     * target object. Returns the target object.
310     * @param target The target object to copy to.
311     * @param sources One or more source objects from which to copy properties
312     */
313    assign(target: object, ...sources: any[]): any;
314
315    /**
316     * Returns an array of all symbol properties found directly on object o.
317     * @param o Object to retrieve the symbols from.
318     */
319    getOwnPropertySymbols(o: any): symbol[];
320
321    /**
322     * Returns the names of the enumerable string properties and methods of an object.
323     * @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.
324     */
325    keys(o: {}): string[];
326
327    /**
328     * Returns true if the values are the same value, false otherwise.
329     * @param value1 The first value.
330     * @param value2 The second value.
331     */
332    is(value1: any, value2: any): boolean;
333
334    /**
335     * Sets the prototype of a specified object o to object proto or null. Returns the object o.
336     * @param o The object to change its prototype.
337     * @param proto The value of the new prototype or null.
338     */
339    setPrototypeOf(o: any, proto: object | null): any;
340}
341
342interface ReadonlyArray<T> {
343    /**
344     * Returns the value of the first element in the array where predicate is true, and undefined
345     * otherwise.
346     * @param predicate find calls predicate once for each element of the array, in ascending
347     * order, until it finds one where predicate returns true. If such an element is found, find
348     * immediately returns that element value. Otherwise, find returns undefined.
349     * @param thisArg If provided, it will be used as the this value for each invocation of
350     * predicate. If it is not provided, undefined is used instead.
351     */
352    find<S extends T>(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
353    find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
354
355    /**
356     * Returns the index of the first element in the array where predicate is true, and -1
357     * otherwise.
358     * @param predicate find calls predicate once for each element of the array, in ascending
359     * order, until it finds one where predicate returns true. If such an element is found,
360     * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
361     * @param thisArg If provided, it will be used as the this value for each invocation of
362     * predicate. If it is not provided, undefined is used instead.
363     */
364    findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
365}
366
367interface RegExp {
368    /**
369     * Returns a string indicating the flags of the regular expression in question. This field is read-only.
370     * The characters in this string are sequenced and concatenated in the following order:
371     *
372     *    - "g" for global
373     *    - "i" for ignoreCase
374     *    - "m" for multiline
375     *    - "u" for unicode
376     *    - "y" for sticky
377     *
378     * If no flags are set, the value is the empty string.
379     */
380    readonly flags: string;
381
382    /**
383     * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
384     * expression. Default is false. Read-only.
385     */
386    readonly sticky: boolean;
387
388    /**
389     * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
390     * expression. Default is false. Read-only.
391     */
392    readonly unicode: boolean;
393}
394
395interface RegExpConstructor {
396    new (pattern: RegExp | string, flags?: string): RegExp;
397    (pattern: RegExp | string, flags?: string): RegExp;
398}
399
400interface String {
401    /**
402     * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
403     * value of the UTF-16 encoded code point starting at the string element at position pos in
404     * the String resulting from converting this object to a String.
405     * If there is no element at that position, the result is undefined.
406     * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
407     */
408    codePointAt(pos: number): number | undefined;
409
410    /**
411     * Returns true if searchString appears as a substring of the result of converting this
412     * object to a String, at one or more positions that are
413     * greater than or equal to position; otherwise, returns false.
414     * @param searchString search string
415     * @param position If position is undefined, 0 is assumed, so as to search all of the String.
416     */
417    includes(searchString: string, position?: number): boolean;
418
419    /**
420     * Returns true if the sequence of elements of searchString converted to a String is the
421     * same as the corresponding elements of this object (converted to a String) starting at
422     * endPosition – length(this). Otherwise returns false.
423     */
424    endsWith(searchString: string, endPosition?: number): boolean;
425
426    /**
427     * Returns the String value result of normalizing the string into the normalization form
428     * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
429     * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
430     * is "NFC"
431     */
432    normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
433
434    /**
435     * Returns the String value result of normalizing the string into the normalization form
436     * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
437     * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
438     * is "NFC"
439     */
440    normalize(form?: string): string;
441
442    /**
443     * Returns a String value that is made from count copies appended together. If count is 0,
444     * the empty string is returned.
445     * @param count number of copies to append
446     */
447    repeat(count: number): string;
448
449    /**
450     * Returns true if the sequence of elements of searchString converted to a String is the
451     * same as the corresponding elements of this object (converted to a String) starting at
452     * position. Otherwise returns false.
453     */
454    startsWith(searchString: string, position?: number): boolean;
455
456    /**
457     * Returns an <a> HTML anchor element and sets the name attribute to the text value
458     * @param name
459     */
460    anchor(name: string): string;
461
462    /** Returns a <big> HTML element */
463    big(): string;
464
465    /** Returns a <blink> HTML element */
466    blink(): string;
467
468    /** Returns a <b> HTML element */
469    bold(): string;
470
471    /** Returns a <tt> HTML element */
472    fixed(): string;
473
474    /** Returns a <font> HTML element and sets the color attribute value */
475    fontcolor(color: string): string;
476
477    /** Returns a <font> HTML element and sets the size attribute value */
478    fontsize(size: number): string;
479
480    /** Returns a <font> HTML element and sets the size attribute value */
481    fontsize(size: string): string;
482
483    /** Returns an <i> HTML element */
484    italics(): string;
485
486    /** Returns an <a> HTML element and sets the href attribute value */
487    link(url: string): string;
488
489    /** Returns a <small> HTML element */
490    small(): string;
491
492    /** Returns a <strike> HTML element */
493    strike(): string;
494
495    /** Returns a <sub> HTML element */
496    sub(): string;
497
498    /** Returns a <sup> HTML element */
499    sup(): string;
500}
501
502interface StringConstructor {
503    /**
504     * Return the String value whose elements are, in order, the elements in the List elements.
505     * If length is 0, the empty string is returned.
506     */
507    fromCodePoint(...codePoints: number[]): string;
508
509    /**
510     * String.raw is intended for use as a tag function of a Tagged Template String. When called
511     * as such the first argument will be a well formed template call site object and the rest
512     * parameter will contain the substitution values.
513     * @param template A well-formed template string call site representation.
514     * @param substitutions A set of substitution values.
515     */
516    raw(template: TemplateStringsArray, ...substitutions: any[]): string;
517}
518