p-cancelable
Advanced tools
Comparing version 4.0.0 to 4.0.1
12
index.js
@@ -40,3 +40,3 @@ export class CancelError extends Error { | ||
resolve(value); | ||
this.#state = promiseState.resolved; | ||
this.#setState(promiseState.resolved); | ||
} | ||
@@ -48,3 +48,3 @@ }; | ||
reject(error); | ||
this.#state = promiseState.rejected; | ||
this.#setState(promiseState.rejected); | ||
} | ||
@@ -92,3 +92,3 @@ }; | ||
this.#state = promiseState.canceled; | ||
this.#setState(promiseState.canceled); | ||
@@ -114,4 +114,10 @@ if (this.#cancelHandlers.length > 0) { | ||
} | ||
#setState(state) { | ||
if (this.#state === promiseState.pending) { | ||
this.#state = state; | ||
} | ||
} | ||
} | ||
Object.setPrototypeOf(PCancelable.prototype, Promise.prototype); |
{ | ||
"name": "p-cancelable", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Create a promise that can be canceled", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
13624
242