1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
\r
21 interface Array<T> {
\r
23 * Returns the value of the first element in the array where predicate is true, and undefined
\r
25 * @param predicate find calls predicate once for each element of the array, in ascending
\r
26 * order, until it finds one where predicate returns true. If such an element is found, find
\r
27 * immediately returns that element value. Otherwise, find returns undefined.
\r
28 * @param thisArg If provided, it will be used as the this value for each invocation of
\r
29 * predicate. If it is not provided, undefined is used instead.
\r
31 find<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
\r
32 find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
\r
35 * Returns the index of the first element in the array where predicate is true, and -1
\r
37 * @param predicate find calls predicate once for each element of the array, in ascending
\r
38 * order, until it finds one where predicate returns true. If such an element is found,
\r
39 * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
\r
40 * @param thisArg If provided, it will be used as the this value for each invocation of
\r
41 * predicate. If it is not provided, undefined is used instead.
\r
43 findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
\r
46 * Returns the this object after filling the section identified by start and end with value
\r
47 * @param value value to fill array section with
\r
48 * @param start index to start filling the array at. If start is negative, it is treated as
\r
49 * length+start where length is the length of the array.
\r
50 * @param end index to stop filling the array at. If end is negative, it is treated as
\r
53 fill(value: T, start?: number, end?: number): this;
\r
56 * Returns the this object after copying a section of the array identified by start and end
\r
57 * to the same array starting at position target
\r
58 * @param target If target is negative, it is treated as length+target where length is the
\r
59 * length of the array.
\r
60 * @param start If start is negative, it is treated as length+start. If end is negative, it
\r
61 * is treated as length+end.
\r
62 * @param end If not specified, length of the this object is used as its default value.
\r
64 copyWithin(target: number, start: number, end?: number): this;
\r
67 interface ArrayConstructor {
\r
69 * Creates an array from an array-like object.
\r
70 * @param arrayLike An array-like object to convert to an array.
\r
72 from<T>(arrayLike: ArrayLike<T>): T[];
\r
75 * Creates an array from an iterable object.
\r
76 * @param arrayLike An array-like object to convert to an array.
\r
77 * @param mapfn A mapping function to call on every element of the array.
\r
78 * @param thisArg Value of 'this' used to invoke the mapfn.
\r
80 from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
\r
83 * Returns a new array from a set of elements.
\r
84 * @param items A set of elements to include in the new array object.
\r
86 of<T>(...items: T[]): T[];
\r
89 interface DateConstructor {
\r
90 new (value: number | string | Date): Date;
\r
93 interface Function {
\r
95 * Returns the name of the function. Function names are read-only and can not be changed.
\r
97 readonly name: string;
\r
102 * Returns the number of leading zero bits in the 32-bit binary representation of a number.
\r
103 * @param x A numeric expression.
\r
105 clz32(x: number): number;
\r
108 * Returns the result of 32-bit multiplication of two numbers.
\r
109 * @param x First number
\r
110 * @param y Second number
\r
112 imul(x: number, y: number): number;
\r
115 * Returns the sign of the x, indicating whether x is positive, negative or zero.
\r
116 * @param x The numeric expression to test
\r
118 sign(x: number): number;
\r
121 * Returns the base 10 logarithm of a number.
\r
122 * @param x A numeric expression.
\r
124 log10(x: number): number;
\r
127 * Returns the base 2 logarithm of a number.
\r
128 * @param x A numeric expression.
\r
130 log2(x: number): number;
\r
133 * Returns the natural logarithm of 1 + x.
\r
134 * @param x A numeric expression.
\r
136 log1p(x: number): number;
\r
139 * Returns the result of (e^x - 1), which is an implementation-dependent approximation to
\r
140 * subtracting 1 from the exponential function of x (e raised to the power of x, where e
\r
141 * is the base of the natural logarithms).
\r
142 * @param x A numeric expression.
\r
144 expm1(x: number): number;
\r
147 * Returns the hyperbolic cosine of a number.
\r
148 * @param x A numeric expression that contains an angle measured in radians.
\r
150 cosh(x: number): number;
\r
153 * Returns the hyperbolic sine of a number.
\r
154 * @param x A numeric expression that contains an angle measured in radians.
\r
156 sinh(x: number): number;
\r
159 * Returns the hyperbolic tangent of a number.
\r
160 * @param x A numeric expression that contains an angle measured in radians.
\r
162 tanh(x: number): number;
\r
165 * Returns the inverse hyperbolic cosine of a number.
\r
166 * @param x A numeric expression that contains an angle measured in radians.
\r
168 acosh(x: number): number;
\r
171 * Returns the inverse hyperbolic sine of a number.
\r
172 * @param x A numeric expression that contains an angle measured in radians.
\r
174 asinh(x: number): number;
\r
177 * Returns the inverse hyperbolic tangent of a number.
\r
178 * @param x A numeric expression that contains an angle measured in radians.
\r
180 atanh(x: number): number;
\r
183 * Returns the square root of the sum of squares of its arguments.
\r
184 * @param values Values to compute the square root for.
\r
185 * If no arguments are passed, the result is +0.
\r
186 * If there is only one argument, the result is the absolute value.
\r
187 * If any argument is +Infinity or -Infinity, the result is +Infinity.
\r
188 * If any argument is NaN, the result is NaN.
\r
189 * If all arguments are either +0 or −0, the result is +0.
\r
191 hypot(...values: number[]): number;
\r
194 * Returns the integral part of the a numeric expression, x, removing any fractional digits.
\r
195 * If x is already an integer, the result is x.
\r
196 * @param x A numeric expression.
\r
198 trunc(x: number): number;
\r
201 * Returns the nearest single precision float representation of a number.
\r
202 * @param x A numeric expression.
\r
204 fround(x: number): number;
\r
207 * Returns an implementation-dependent approximation to the cube root of number.
\r
208 * @param x A numeric expression.
\r
210 cbrt(x: number): number;
\r
213 interface NumberConstructor {
\r
215 * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
\r
216 * that is representable as a Number value, which is approximately:
\r
217 * 2.2204460492503130808472633361816 x 10−16.
\r
219 readonly EPSILON: number;
\r
222 * Returns true if passed value is finite.
\r
223 * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
\r
224 * number. Only finite values of the type number, result in true.
\r
225 * @param number A numeric value.
\r
227 isFinite(number: unknown): boolean;
\r
230 * Returns true if the value passed is an integer, false otherwise.
\r
231 * @param number A numeric value.
\r
233 isInteger(number: unknown): boolean;
\r
236 * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
\r
237 * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
\r
238 * to a number. Only values of the type number, that are also NaN, result in true.
\r
239 * @param number A numeric value.
\r
241 isNaN(number: unknown): boolean;
\r
244 * Returns true if the value passed is a safe integer.
\r
245 * @param number A numeric value.
\r
247 isSafeInteger(number: unknown): boolean;
\r
250 * The value of the largest integer n such that n and n + 1 are both exactly representable as
\r
252 * The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
\r
254 readonly MAX_SAFE_INTEGER: number;
\r
257 * The value of the smallest integer n such that n and n − 1 are both exactly representable as
\r
259 * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
\r
261 readonly MIN_SAFE_INTEGER: number;
\r
264 * Converts a string to a floating-point number.
\r
265 * @param string A string that contains a floating-point number.
\r
267 parseFloat(string: string): number;
\r
270 * Converts A string to an integer.
\r
271 * @param s A string to convert into a number.
\r
272 * @param radix A value between 2 and 36 that specifies the base of the number in numString.
\r
273 * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
\r
274 * All other strings are considered decimal.
\r
276 parseInt(string: string, radix?: number): number;
\r
279 interface ObjectConstructor {
\r
281 * Copy the values of all of the enumerable own properties from one or more source objects to a
\r
282 * target object. Returns the target object.
\r
283 * @param target The target object to copy to.
\r
284 * @param source The source object from which to copy properties.
\r
286 assign<T, U>(target: T, source: U): T & U;
\r
289 * Copy the values of all of the enumerable own properties from one or more source objects to a
\r
290 * target object. Returns the target object.
\r
291 * @param target The target object to copy to.
\r
292 * @param source1 The first source object from which to copy properties.
\r
293 * @param source2 The second source object from which to copy properties.
\r
295 assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
\r
298 * Copy the values of all of the enumerable own properties from one or more source objects to a
\r
299 * target object. Returns the target object.
\r
300 * @param target The target object to copy to.
\r
301 * @param source1 The first source object from which to copy properties.
\r
302 * @param source2 The second source object from which to copy properties.
\r
303 * @param source3 The third source object from which to copy properties.
\r
305 assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
\r
308 * Copy the values of all of the enumerable own properties from one or more source objects to a
\r
309 * target object. Returns the target object.
\r
310 * @param target The target object to copy to.
\r
311 * @param sources One or more source objects from which to copy properties
\r
313 assign(target: object, ...sources: any[]): any;
\r
316 * Returns an array of all symbol properties found directly on object o.
\r
317 * @param o Object to retrieve the symbols from.
\r
319 getOwnPropertySymbols(o: any): symbol[];
\r
322 * Returns the names of the enumerable string properties and methods of an object.
\r
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.
\r
325 keys(o: {}): string[];
\r
328 * Returns true if the values are the same value, false otherwise.
\r
329 * @param value1 The first value.
\r
330 * @param value2 The second value.
\r
332 is(value1: any, value2: any): boolean;
\r
335 * Sets the prototype of a specified object o to object proto or null. Returns the object o.
\r
336 * @param o The object to change its prototype.
\r
337 * @param proto The value of the new prototype or null.
\r
339 setPrototypeOf(o: any, proto: object | null): any;
\r
342 interface ReadonlyArray<T> {
\r
344 * Returns the value of the first element in the array where predicate is true, and undefined
\r
346 * @param predicate find calls predicate once for each element of the array, in ascending
\r
347 * order, until it finds one where predicate returns true. If such an element is found, find
\r
348 * immediately returns that element value. Otherwise, find returns undefined.
\r
349 * @param thisArg If provided, it will be used as the this value for each invocation of
\r
350 * predicate. If it is not provided, undefined is used instead.
\r
352 find<S extends T>(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined;
\r
353 find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined;
\r
356 * Returns the index of the first element in the array where predicate is true, and -1
\r
358 * @param predicate find calls predicate once for each element of the array, in ascending
\r
359 * order, until it finds one where predicate returns true. If such an element is found,
\r
360 * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
\r
361 * @param thisArg If provided, it will be used as the this value for each invocation of
\r
362 * predicate. If it is not provided, undefined is used instead.
\r
364 findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number;
\r
369 * Returns a string indicating the flags of the regular expression in question. This field is read-only.
\r
370 * The characters in this string are sequenced and concatenated in the following order:
\r
373 * - "i" for ignoreCase
\r
374 * - "m" for multiline
\r
375 * - "u" for unicode
\r
378 * If no flags are set, the value is the empty string.
\r
380 readonly flags: string;
\r
383 * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
\r
384 * expression. Default is false. Read-only.
\r
386 readonly sticky: boolean;
\r
389 * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
\r
390 * expression. Default is false. Read-only.
\r
392 readonly unicode: boolean;
\r
395 interface RegExpConstructor {
\r
396 new (pattern: RegExp | string, flags?: string): RegExp;
\r
397 (pattern: RegExp | string, flags?: string): RegExp;
\r
402 * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
\r
403 * value of the UTF-16 encoded code point starting at the string element at position pos in
\r
404 * the String resulting from converting this object to a String.
\r
405 * If there is no element at that position, the result is undefined.
\r
406 * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
\r
408 codePointAt(pos: number): number | undefined;
\r
411 * Returns true if searchString appears as a substring of the result of converting this
\r
412 * object to a String, at one or more positions that are
\r
413 * greater than or equal to position; otherwise, returns false.
\r
414 * @param searchString search string
\r
415 * @param position If position is undefined, 0 is assumed, so as to search all of the String.
\r
417 includes(searchString: string, position?: number): boolean;
\r
420 * Returns true if the sequence of elements of searchString converted to a String is the
\r
421 * same as the corresponding elements of this object (converted to a String) starting at
\r
422 * endPosition – length(this). Otherwise returns false.
\r
424 endsWith(searchString: string, endPosition?: number): boolean;
\r
427 * Returns the String value result of normalizing the string into the normalization form
\r
428 * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
\r
429 * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
\r
432 normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
\r
435 * Returns the String value result of normalizing the string into the normalization form
\r
436 * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
\r
437 * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
\r
440 normalize(form?: string): string;
\r
443 * Returns a String value that is made from count copies appended together. If count is 0,
\r
444 * the empty string is returned.
\r
445 * @param count number of copies to append
\r
447 repeat(count: number): string;
\r
450 * Returns true if the sequence of elements of searchString converted to a String is the
\r
451 * same as the corresponding elements of this object (converted to a String) starting at
\r
452 * position. Otherwise returns false.
\r
454 startsWith(searchString: string, position?: number): boolean;
\r
457 * Returns an `<a>` HTML anchor element and sets the name attribute to the text value
\r
460 anchor(name: string): string;
\r
462 /** Returns a `<big>` HTML element */
\r
465 /** Returns a `<blink>` HTML element */
\r
468 /** Returns a `<b>` HTML element */
\r
471 /** Returns a `<tt>` HTML element */
\r
474 /** Returns a `<font>` HTML element and sets the color attribute value */
\r
475 fontcolor(color: string): string;
\r
477 /** Returns a `<font>` HTML element and sets the size attribute value */
\r
478 fontsize(size: number): string;
\r
480 /** Returns a `<font>` HTML element and sets the size attribute value */
\r
481 fontsize(size: string): string;
\r
483 /** Returns an `<i>` HTML element */
\r
486 /** Returns an `<a>` HTML element and sets the href attribute value */
\r
487 link(url: string): string;
\r
489 /** Returns a `<small>` HTML element */
\r
492 /** Returns a `<strike>` HTML element */
\r
495 /** Returns a `<sub>` HTML element */
\r
498 /** Returns a `<sup>` HTML element */
\r
502 interface StringConstructor {
\r
504 * Return the String value whose elements are, in order, the elements in the List elements.
\r
505 * If length is 0, the empty string is returned.
\r
507 fromCodePoint(...codePoints: number[]): string;
\r
510 * String.raw is intended for use as a tag function of a Tagged Template String. When called
\r
511 * as such the first argument will be a well formed template call site object and the rest
\r
512 * parameter will contain the substitution values.
\r
513 * @param template A well-formed template string call site representation.
\r
514 * @param substitutions A set of substitution values.
\r
516 raw(template: TemplateStringsArray, ...substitutions: any[]): string;
\r