lib.es2015.core.d.ts 22 KB

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