lib.es2015.core.d.ts 21 KB

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