From a2d802169daef5c9b56c3466d04a783d201e3b62 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Tue, 25 Dec 2018 22:20:54 +0100 Subject: [PATCH] add isAborted to Abortable interface --- src/abortAble.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/abortAble.ts b/src/abortAble.ts index ea14076..54e4d96 100644 --- a/src/abortAble.ts +++ b/src/abortAble.ts @@ -5,6 +5,7 @@ export function isPromiseLike(p: PromiseLike | any): p is PromiseLike export interface IAbortAblePromiseBase extends PromiseLike { then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): IAbortAblePromiseBase; abort(): void; + isAborted(): boolean; } export declare type IAbortAblePromise = IAbortAblePromiseBase; @@ -33,7 +34,8 @@ function thenFactory(loader: PromiseLike, isAborted: () => boolea }); return { then: thenFactory(fullfiller, isAborted, abort), - abort + abort, + isAborted }; } return then; @@ -60,7 +62,8 @@ export default function abortAble(loader: PromiseLike): IAAP { return { then: thenFactory(race, isAborted, abort), - abort + abort, + isAborted }; } @@ -96,7 +99,8 @@ export function abortAbleAll(values: any[]): IAAP { return { then: thenFactory(race, isAborted, abort), - abort + abort, + isAborted }; } @@ -125,11 +129,13 @@ export function abortAbleResolveNow(value: T) { } return { then: abortAbleResolveNow(res), - abort: () => undefined + abort: () => undefined, + isAborted: () => false }; } return { then, - abort: () => undefined + abort: () => undefined, + isAborted: () => false }; }