Debian Codegraph @

types-es6-shim/index.d.ts

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