UNPKG

1.35 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14export declare type CancelFunction = (reason?: any) => void;
15/**
16 * A polyfill for the November 23rd, 2016 draft of
17 * https://tc39.github.io/proposal-cancelable-promises/
18 */
19export declare class CancelToken {
20 promise: Promise<Cancel>;
21 reason: Cancel | undefined;
22 constructor(executor: (cancel: CancelFunction) => void);
23 static source(): {
24 token: CancelToken;
25 cancel: CancelFunction;
26 };
27 static race(tokens: Iterable<CancelToken>): CancelToken;
28 throwIfRequested(): void;
29 readonly [Symbol.toStringTag]: string;
30}
31export declare class Cancel {
32 message: string;
33 constructor(reason?: any);
34 toString(): string;
35}
36export declare function isCancel(value: any): value is Cancel;
37export declare function isCancelToken(value: any): value is CancelToken;