blob: 6ad8cedcd3319d22ab4174856b8ff3b17468e78b [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001// Generated by typings
2// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/9807d9b701f58be068cb07833d2b24235351d052/es6-shim/es6-shim.d.ts
3declare type PropertyKey = string | number | symbol;
4
5interface IteratorResult<T> {
6 done: boolean;
7 value?: T;
8}
9
10interface IterableShim<T> {
11 /**
12 * Shim for an ES6 iterable. Not intended for direct use by user code.
13 */
14 "_es6-shim iterator_"(): Iterator<T>;
15}
16
17interface Iterator<T> {
18 next(value?: any): IteratorResult<T>;
19 return?(value?: any): IteratorResult<T>;
20 throw?(e?: any): IteratorResult<T>;
21}
22
23interface IterableIteratorShim<T> extends IterableShim<T>, Iterator<T> {
24 /**
25 * Shim for an ES6 iterable iterator. Not intended for direct use by user code.
26 */
27 "_es6-shim iterator_"(): IterableIteratorShim<T>;
28}
29
30interface StringConstructor {
31 /**
32 * Return the String value whose elements are, in order, the elements in the List elements.
33 * If length is 0, the empty string is returned.
34 */
35 fromCodePoint(...codePoints: number[]): string;
36
37 /**
38 * String.raw is intended for use as a tag function of a Tagged Template String. When called
39 * as such the first argument will be a well formed template call site object and the rest
40 * parameter will contain the substitution values.
41 * @param template A well-formed template string call site representation.
42 * @param substitutions A set of substitution values.
43 */
44 raw(template: TemplateStringsArray, ...substitutions: any[]): string;
45}
46
47interface String {
48 /**
49 * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
50 * value of the UTF-16 encoded code point starting at the string element at position pos in
51 * the String resulting from converting this object to a String.
52 * If there is no element at that position, the result is undefined.
53 * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
54 */
55 codePointAt(pos: number): number;
56
57 /**
58 * Returns true if searchString appears as a substring of the result of converting this
59 * object to a String, at one or more positions that are
60 * greater than or equal to position; otherwise, returns false.
61 * @param searchString search string
62 * @param position If position is undefined, 0 is assumed, so as to search all of the String.
63 */
64 includes(searchString: string, position?: number): boolean;
65
66 /**
67 * Returns true if the sequence of elements of searchString converted to a String is the
68 * same as the corresponding elements of this object (converted to a String) starting at
69 * endPosition – length(this). Otherwise returns false.
70 */
71 endsWith(searchString: string, endPosition?: number): boolean;
72
73 /**
74 * Returns a String value that is made from count copies appended together. If count is 0,
75 * T is the empty String is returned.
76 * @param count number of copies to append
77 */
78 repeat(count: number): string;
79
80 /**
81 * Returns true if the sequence of elements of searchString converted to a String is the
82 * same as the corresponding elements of this object (converted to a String) starting at
83 * position. Otherwise returns false.
84 */
85 startsWith(searchString: string, position?: number): boolean;
86
87 /**
88 * Returns an <a> HTML anchor element and sets the name attribute to the text value
89 * @param name
90 */
91 anchor(name: string): string;
92
93 /** Returns a <big> HTML element */
94 big(): string;
95
96 /** Returns a <blink> HTML element */
97 blink(): string;
98
99 /** Returns a <b> HTML element */
100 bold(): string;
101
102 /** Returns a <tt> HTML element */
103 fixed(): string
104
105 /** Returns a <font> HTML element and sets the color attribute value */
106 fontcolor(color: string): string
107
108 /** Returns a <font> HTML element and sets the size attribute value */
109 fontsize(size: number): string;
110
111 /** Returns a <font> HTML element and sets the size attribute value */
112 fontsize(size: string): string;
113
114 /** Returns an <i> HTML element */
115 italics(): string;
116
117 /** Returns an <a> HTML element and sets the href attribute value */
118 link(url: string): string;
119
120 /** Returns a <small> HTML element */
121 small(): string;
122
123 /** Returns a <strike> HTML element */
124 strike(): string;
125
126 /** Returns a <sub> HTML element */
127 sub(): string;
128
129 /** Returns a <sup> HTML element */
130 sup(): string;
131
132 /**
133 * Shim for an ES6 iterable. Not intended for direct use by user code.
134 */
135 "_es6-shim iterator_"(): IterableIteratorShim<string>;
136}
137
138interface ArrayConstructor {
139 /**
140 * Creates an array from an array-like object.
141 * @param arrayLike An array-like object to convert to an array.
142 * @param mapfn A mapping function to call on every element of the array.
143 * @param thisArg Value of 'this' used to invoke the mapfn.
144 */
145 from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
146
147 /**
148 * Creates an array from an iterable object.
149 * @param iterable An iterable object to convert to an array.
150 * @param mapfn A mapping function to call on every element of the array.
151 * @param thisArg Value of 'this' used to invoke the mapfn.
152 */
153 from<T, U>(iterable: IterableShim<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
154
155 /**
156 * Creates an array from an array-like object.
157 * @param arrayLike An array-like object to convert to an array.
158 */
159 from<T>(arrayLike: ArrayLike<T>): Array<T>;
160
161 /**
162 * Creates an array from an iterable object.
163 * @param iterable An iterable object to convert to an array.
164 */
165 from<T>(iterable: IterableShim<T>): Array<T>;
166
167 /**
168 * Returns a new array from a set of elements.
169 * @param items A set of elements to include in the new array object.
170 */
171 of<T>(...items: T[]): Array<T>;
172}
173
174interface Array<T> {
175 /**
176 * Returns the value of the first element in the array where predicate is true, and undefined
177 * otherwise.
178 * @param predicate find calls predicate once for each element of the array, in ascending
179 * order, until it finds one where predicate returns true. If such an element is found, find
180 * immediately returns that element value. Otherwise, find returns undefined.
181 * @param thisArg If provided, it will be used as the this value for each invocation of
182 * predicate. If it is not provided, undefined is used instead.
183 */
184 find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
185
186 /**
187 * Returns the index of the first element in the array where predicate is true, and undefined
188 * otherwise.
189 * @param predicate find calls predicate once for each element of the array, in ascending
190 * order, until it finds one where predicate returns true. If such an element is found, find
191 * immediately returns that element value. Otherwise, find returns undefined.
192 * @param thisArg If provided, it will be used as the this value for each invocation of
193 * predicate. If it is not provided, undefined is used instead.
194 */
195 findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
196
197 /**
198 * Returns the this object after filling the section identified by start and end with value
199 * @param value value to fill array section with
200 * @param start index to start filling the array at. If start is negative, it is treated as
201 * length+start where length is the length of the array.
202 * @param end index to stop filling the array at. If end is negative, it is treated as
203 * length+end.
204 */
205 fill(value: T, start?: number, end?: number): T[];
206
207 /**
208 * Returns the this object after copying a section of the array identified by start and end
209 * to the same array starting at position target
210 * @param target If target is negative, it is treated as length+target where length is the
211 * length of the array.
212 * @param start If start is negative, it is treated as length+start. If end is negative, it
213 * is treated as length+end.
214 * @param end If not specified, length of the this object is used as its default value.
215 */
216 copyWithin(target: number, start: number, end?: number): T[];
217
218 /**
219 * Returns an array of key, value pairs for every entry in the array
220 */
221 entries(): IterableIteratorShim<[number, T]>;
222
223 /**
224 * Returns an list of keys in the array
225 */
226 keys(): IterableIteratorShim<number>;
227
228 /**
229 * Returns an list of values in the array
230 */
231 values(): IterableIteratorShim<T>;
232
233 /**
234 * Shim for an ES6 iterable. Not intended for direct use by user code.
235 */
236 "_es6-shim iterator_"(): IterableIteratorShim<T>;
237}
238
239interface NumberConstructor {
240 /**
241 * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
242 * that is representable as a Number value, which is approximately:
243 * 2.2204460492503130808472633361816 x 10‍−‍16.
244 */
245 EPSILON: number;
246
247 /**
248 * Returns true if passed value is finite.
249 * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
250 * number. Only finite values of the type number, result in true.
251 * @param number A numeric value.
252 */
253 isFinite(number: number): boolean;
254
255 /**
256 * Returns true if the value passed is an integer, false otherwise.
257 * @param number A numeric value.
258 */
259 isInteger(number: number): boolean;
260
261 /**
262 * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
263 * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
264 * to a number. Only values of the type number, that are also NaN, result in true.
265 * @param number A numeric value.
266 */
267 isNaN(number: number): boolean;
268
269 /**
270 * Returns true if the value passed is a safe integer.
271 * @param number A numeric value.
272 */
273 isSafeInteger(number: number): boolean;
274
275 /**
276 * The value of the largest integer n such that n and n + 1 are both exactly representable as
277 * a Number value.
278 * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1.
279 */
280 MAX_SAFE_INTEGER: number;
281
282 /**
283 * The value of the smallest integer n such that n and n − 1 are both exactly representable as
284 * a Number value.
285 * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
286 */
287 MIN_SAFE_INTEGER: number;
288
289 /**
290 * Converts a string to a floating-point number.
291 * @param string A string that contains a floating-point number.
292 */
293 parseFloat(string: string): number;
294
295 /**
296 * Converts A string to an integer.
297 * @param s A string to convert into a number.
298 * @param radix A value between 2 and 36 that specifies the base of the number in numString.
299 * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
300 * All other strings are considered decimal.
301 */
302 parseInt(string: string, radix?: number): number;
303}
304
305interface ObjectConstructor {
306 /**
307 * Copy the values of all of the enumerable own properties from one or more source objects to a
308 * target object. Returns the target object.
309 * @param target The target object to copy to.
310 * @param sources One or more source objects to copy properties from.
311 */
312 assign(target: any, ...sources: any[]): any;
313
314 /**
315 * Returns true if the values are the same value, false otherwise.
316 * @param value1 The first value.
317 * @param value2 The second value.
318 */
319 is(value1: any, value2: any): boolean;
320
321 /**
322 * Sets the prototype of a specified object o to object proto or null. Returns the object o.
323 * @param o The object to change its prototype.
324 * @param proto The value of the new prototype or null.
325 * @remarks Requires `__proto__` support.
326 */
327 setPrototypeOf(o: any, proto: any): any;
328}
329
330interface RegExp {
331 /**
332 * Returns a string indicating the flags of the regular expression in question. This field is read-only.
333 * The characters in this string are sequenced and concatenated in the following order:
334 *
335 * - "g" for global
336 * - "i" for ignoreCase
337 * - "m" for multiline
338 * - "u" for unicode
339 * - "y" for sticky
340 *
341 * If no flags are set, the value is the empty string.
342 */
343 flags: string;
344}
345
346interface Math {
347 /**
348 * Returns the number of leading zero bits in the 32-bit binary representation of a number.
349 * @param x A numeric expression.
350 */
351 clz32(x: number): number;
352
353 /**
354 * Returns the result of 32-bit multiplication of two numbers.
355 * @param x First number
356 * @param y Second number
357 */
358 imul(x: number, y: number): number;
359
360 /**
361 * Returns the sign of the x, indicating whether x is positive, negative or zero.
362 * @param x The numeric expression to test
363 */
364 sign(x: number): number;
365
366 /**
367 * Returns the base 10 logarithm of a number.
368 * @param x A numeric expression.
369 */
370 log10(x: number): number;
371
372 /**
373 * Returns the base 2 logarithm of a number.
374 * @param x A numeric expression.
375 */
376 log2(x: number): number;
377
378 /**
379 * Returns the natural logarithm of 1 + x.
380 * @param x A numeric expression.
381 */
382 log1p(x: number): number;
383
384 /**
385 * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
386 * the natural logarithms).
387 * @param x A numeric expression.
388 */
389 expm1(x: number): number;
390
391 /**
392 * Returns the hyperbolic cosine of a number.
393 * @param x A numeric expression that contains an angle measured in radians.
394 */
395 cosh(x: number): number;
396
397 /**
398 * Returns the hyperbolic sine of a number.
399 * @param x A numeric expression that contains an angle measured in radians.
400 */
401 sinh(x: number): number;
402
403 /**
404 * Returns the hyperbolic tangent of a number.
405 * @param x A numeric expression that contains an angle measured in radians.
406 */
407 tanh(x: number): number;
408
409 /**
410 * Returns the inverse hyperbolic cosine of a number.
411 * @param x A numeric expression that contains an angle measured in radians.
412 */
413 acosh(x: number): number;
414
415 /**
416 * Returns the inverse hyperbolic sine of a number.
417 * @param x A numeric expression that contains an angle measured in radians.
418 */
419 asinh(x: number): number;
420
421 /**
422 * Returns the inverse hyperbolic tangent of a number.
423 * @param x A numeric expression that contains an angle measured in radians.
424 */
425 atanh(x: number): number;
426
427 /**
428 * Returns the square root of the sum of squares of its arguments.
429 * @param values Values to compute the square root for.
430 * If no arguments are passed, the result is +0.
431 * If there is only one argument, the result is the absolute value.
432 * If any argument is +Infinity or -Infinity, the result is +Infinity.
433 * If any argument is NaN, the result is NaN.
434 * If all arguments are either +0 or −0, the result is +0.
435 */
436 hypot(...values: number[]): number;
437
438 /**
439 * Returns the integral part of the a numeric expression, x, removing any fractional digits.
440 * If x is already an integer, the result is x.
441 * @param x A numeric expression.
442 */
443 trunc(x: number): number;
444
445 /**
446 * Returns the nearest single precision float representation of a number.
447 * @param x A numeric expression.
448 */
449 fround(x: number): number;
450
451 /**
452 * Returns an implementation-dependent approximation to the cube root of number.
453 * @param x A numeric expression.
454 */
455 cbrt(x: number): number;
456}
457
458interface PromiseLike<T> {
459 /**
460 * Attaches callbacks for the resolution and/or rejection of the Promise.
461 * @param onfulfilled The callback to execute when the Promise is resolved.
462 * @param onrejected The callback to execute when the Promise is rejected.
463 * @returns A Promise for the completion of which ever callback is executed.
464 */
465 then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
466 then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
467}
468
469/**
470 * Represents the completion of an asynchronous operation
471 */
472interface Promise<T> {
473 /**
474 * Attaches callbacks for the resolution and/or rejection of the Promise.
475 * @param onfulfilled The callback to execute when the Promise is resolved.
476 * @param onrejected The callback to execute when the Promise is rejected.
477 * @returns A Promise for the completion of which ever callback is executed.
478 */
479 then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
480 then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
481
482 /**
483 * Attaches a callback for only the rejection of the Promise.
484 * @param onrejected The callback to execute when the Promise is rejected.
485 * @returns A Promise for the completion of the callback.
486 */
487 catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
488 catch(onrejected?: (reason: any) => void): Promise<T>;
489}
490
491interface PromiseConstructor {
492 /**
493 * A reference to the prototype.
494 */
495 prototype: Promise<any>;
496
497 /**
498 * Creates a new Promise.
499 * @param executor A callback used to initialize the promise. This callback is passed two arguments:
500 * a resolve callback used resolve the promise with a value or the result of another promise,
501 * and a reject callback used to reject the promise with a provided reason or error.
502 */
503 new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
504
505 /**
506 * Creates a Promise that is resolved with an array of results when all of the provided Promises
507 * resolve, or rejected when any Promise is rejected.
508 * @param values An array of Promises.
509 * @returns A new Promise.
510 */
511 all<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T[]>;
512
513 /**
514 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
515 * or rejected.
516 * @param values An array of Promises.
517 * @returns A new Promise.
518 */
519 race<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T>;
520
521 /**
522 * Creates a new rejected promise for the provided reason.
523 * @param reason The reason the promise was rejected.
524 * @returns A new rejected Promise.
525 */
526 reject(reason: any): Promise<void>;
527
528 /**
529 * Creates a new rejected promise for the provided reason.
530 * @param reason The reason the promise was rejected.
531 * @returns A new rejected Promise.
532 */
533 reject<T>(reason: any): Promise<T>;
534
535 /**
536 * Creates a new resolved promise for the provided value.
537 * @param value A promise.
538 * @returns A promise whose internal state matches the provided promise.
539 */
540 resolve<T>(value: T | PromiseLike<T>): Promise<T>;
541
542 /**
543 * Creates a new resolved promise .
544 * @returns A resolved promise.
545 */
546 resolve(): Promise<void>;
547}
548
549declare var Promise: PromiseConstructor;
550
551interface Map<K, V> {
552 clear(): void;
553 delete(key: K): boolean;
554 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
555 get(key: K): V;
556 has(key: K): boolean;
557 set(key: K, value?: V): Map<K, V>;
558 size: number;
559 entries(): IterableIteratorShim<[K, V]>;
560 keys(): IterableIteratorShim<K>;
561 values(): IterableIteratorShim<V>;
562}
563
564interface MapConstructor {
565 new <K, V>(): Map<K, V>;
566 new <K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
567 prototype: Map<any, any>;
568}
569
570declare var Map: MapConstructor;
571
572interface Set<T> {
573 add(value: T): Set<T>;
574 clear(): void;
575 delete(value: T): boolean;
576 forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
577 has(value: T): boolean;
578 size: number;
579 entries(): IterableIteratorShim<[T, T]>;
580 keys(): IterableIteratorShim<T>;
581 values(): IterableIteratorShim<T>;
582 '_es6-shim iterator_'(): IterableIteratorShim<T>;
583}
584
585interface SetConstructor {
586 new <T>(): Set<T>;
587 new <T>(iterable: IterableShim<T>): Set<T>;
588 prototype: Set<any>;
589}
590
591declare var Set: SetConstructor;
592
593interface WeakMap<K, V> {
594 delete(key: K): boolean;
595 get(key: K): V;
596 has(key: K): boolean;
597 set(key: K, value?: V): WeakMap<K, V>;
598}
599
600interface WeakMapConstructor {
601 new <K, V>(): WeakMap<K, V>;
602 new <K, V>(iterable: IterableShim<[K, V]>): WeakMap<K, V>;
603 prototype: WeakMap<any, any>;
604}
605
606declare var WeakMap: WeakMapConstructor;
607
608interface WeakSet<T> {
609 add(value: T): WeakSet<T>;
610 delete(value: T): boolean;
611 has(value: T): boolean;
612}
613
614interface WeakSetConstructor {
615 new <T>(): WeakSet<T>;
616 new <T>(iterable: IterableShim<T>): WeakSet<T>;
617 prototype: WeakSet<any>;
618}
619
620declare var WeakSet: WeakSetConstructor;
621
622declare namespace Reflect {
623 function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
624 function construct(target: Function, argumentsList: ArrayLike<any>): any;
625 function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
626 function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
627 function enumerate(target: any): IterableIteratorShim<any>;
628 function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
629 function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
630 function getPrototypeOf(target: any): any;
631 function has(target: any, propertyKey: PropertyKey): boolean;
632 function isExtensible(target: any): boolean;
633 function ownKeys(target: any): Array<PropertyKey>;
634 function preventExtensions(target: any): boolean;
635 function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
636 function setPrototypeOf(target: any, proto: any): boolean;
637}
638
639declare module "es6-shim" {
640 var String: StringConstructor;
641 var Array: ArrayConstructor;
642 var Number: NumberConstructor;
643 var Math: Math;
644 var Object: ObjectConstructor;
645 var Map: MapConstructor;
646 var Set: SetConstructor;
647 var WeakMap: WeakMapConstructor;
648 var WeakSet: WeakSetConstructor;
649 var Promise: PromiseConstructor;
650 namespace Reflect {
651 function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
652 function construct(target: Function, argumentsList: ArrayLike<any>): any;
653 function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
654 function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
655 function enumerate(target: any): Iterator<any>;
656 function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
657 function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
658 function getPrototypeOf(target: any): any;
659 function has(target: any, propertyKey: PropertyKey): boolean;
660 function isExtensible(target: any): boolean;
661 function ownKeys(target: any): Array<PropertyKey>;
662 function preventExtensions(target: any): boolean;
663 function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
664 function setPrototypeOf(target: any, proto: any): boolean;
665 }
666}