123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- // ES6 Promises
- // From https://github.com/Microsoft/TypeScript/blob/0aef9440f28609ead886a1745f52d2a517326fde/lib/lib.es6.d.ts
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- interface SymbolConstructor {
- /**
- * A reference to the prototype.
- */
- prototype: Symbol;
- /**
- * Returns a new unique Symbol value.
- * @param description Description of the new Symbol object.
- */
- (description?: string|number): symbol;
- /**
- * Returns a Symbol object from the global symbol registry matching the given key if found.
- * Otherwise, returns a new symbol with this key.
- * @param key key to search for.
- */
- for(key: string): symbol;
- /**
- * Returns a key from the global symbol registry matching the given Symbol if found.
- * Otherwise, returns a undefined.
- * @param sym Symbol to find the key for.
- */
- keyFor(sym: symbol): string;
- // Well-known Symbols
- /**
- * A method that determines if a constructor object recognizes an object as one of the
- * constructor’s instances. Called by the semantics of the instanceof operator.
- */
- hasInstance: symbol;
- /**
- * A Boolean value that if true indicates that an object should flatten to its array elements
- * by Array.prototype.concat.
- */
- isConcatSpreadable: symbol;
- /**
- * A method that returns the default iterator for an object. Called by the semantics of the
- * for-of statement.
- */
- iterator: symbol;
- /**
- * A regular expression method that matches the regular expression against a string. Called
- * by the String.prototype.match method.
- */
- match: symbol;
- /**
- * A regular expression method that replaces matched substrings of a string. Called by the
- * String.prototype.replace method.
- */
- replace: symbol;
- /**
- * A regular expression method that returns the index within a string that matches the
- * regular expression. Called by the String.prototype.search method.
- */
- search: symbol;
- /**
- * A function valued property that is the constructor function that is used to create
- * derived objects.
- */
- species: symbol;
- /**
- * A regular expression method that splits a string at the indices that match the regular
- * expression. Called by the String.prototype.split method.
- */
- split: symbol;
- /**
- * A method that converts an object to a corresponding primitive value.
- * Called by the ToPrimitive abstract operation.
- */
- toPrimitive: symbol;
- /**
- * A String value that is used in the creation of the default string description of an object.
- * Called by the built-in method Object.prototype.toString.
- */
- toStringTag: symbol;
- /**
- * An Object whose own property names are property names that are excluded from the 'with'
- * environment bindings of the associated objects.
- */
- unscopables: symbol;
- }
- declare var Symbol: SymbolConstructor;
- interface Symbol {
- /** Returns a string representation of an object. */
- toString(): string;
- /** Returns the primitive value of the specified object. */
- valueOf(): Object;
- [Symbol.toStringTag]: string;
- }
- interface IteratorResult<T> {
- done: boolean;
- value?: T;
- }
- interface Iterator<T> {
- next(value?: any): IteratorResult<T>;
- return?(value?: any): IteratorResult<T>;
- throw?(e?: any): IteratorResult<T>;
- }
- interface Iterable<T> {
- [Symbol.iterator](): Iterator<T>;
- }
- /**
- * Represents the completion of an asynchronous operation
- */
- interface Promise<T> {
- /**
- * Attaches callbacks for the resolution and/or rejection of the Promise.
- * @param onfulfilled The callback to execute when the Promise is resolved.
- * @param onrejected The callback to execute when the Promise is rejected.
- * @returns A Promise for the completion of which ever callback is executed.
- */
- then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
- then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
- /**
- * Attaches a callback for only the rejection of the Promise.
- * @param onrejected The callback to execute when the Promise is rejected.
- * @returns A Promise for the completion of the callback.
- */
- catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
- catch(onrejected?: (reason: any) => void): Promise<T>;
- }
- interface PromiseLike<T> {
- /**
- * Attaches callbacks for the resolution and/or rejection of the Promise.
- * @param onfulfilled The callback to execute when the Promise is resolved.
- * @param onrejected The callback to execute when the Promise is rejected.
- * @returns A Promise for the completion of which ever callback is executed.
- */
- then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
- then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
- }
- interface PromiseConstructor {
- /**
- * A reference to the prototype.
- */
- prototype: Promise<any>;
- /**
- * Creates a new Promise.
- * @param executor A callback used to initialize the promise. This callback is passed two arguments:
- * a resolve callback used resolve the promise with a value or the result of another promise,
- * and a reject callback used to reject the promise with a provided reason or error.
- */
- new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
- /**
- * Creates a Promise that is resolved with an array of results when all of the provided Promises
- * resolve, or rejected when any Promise is rejected.
- * @param values An array of Promises.
- * @returns A new Promise.
- */
- all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
- /**
- * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
- * or rejected.
- * @param values An array of Promises.
- * @returns A new Promise.
- */
- race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
- /**
- * Creates a new rejected promise for the provided reason.
- * @param reason The reason the promise was rejected.
- * @returns A new rejected Promise.
- */
- reject(reason: any): Promise<void>;
- /**
- * Creates a new rejected promise for the provided reason.
- * @param reason The reason the promise was rejected.
- * @returns A new rejected Promise.
- */
- reject<T>(reason: any): Promise<T>;
- /**
- * Creates a new resolved promise for the provided value.
- * @param value A promise.
- * @returns A promise whose internal state matches the provided promise.
- */
- resolve<T>(value: T | PromiseLike<T>): Promise<T>;
- /**
- * Creates a new resolved promise .
- * @returns A resolved promise.
- */
- resolve(): Promise<void>;
- [Symbol.species]: Function;
- }
- declare var Promise: PromiseConstructor;
- // *just* for jupyter-js-services, which uses a different name.
- declare type Thenable<T> = PromiseLike<T>;
|