more-proms 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,7 @@ export declare class ResablePromise<T = void> extends SettledPromise<T> {
|
|
|
16
16
|
export declare class CancelAblePromise<T = unknown, C = unknown> extends SettledPromise<T> {
|
|
17
17
|
cancelled: boolean;
|
|
18
18
|
cancel: () => void;
|
|
19
|
+
onCancel: Promise<void>;
|
|
19
20
|
private nestedCancels;
|
|
20
21
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, cancel?: () => C);
|
|
21
22
|
then<TResult1 = T, TResult2 = never>(onfulfilled: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): CancelAblePromise<TResult1 | TResult2>;
|
|
@@ -97,6 +97,7 @@ class CancelAblePromise extends SettledPromise {
|
|
|
97
97
|
executor(r, rj);
|
|
98
98
|
});
|
|
99
99
|
this.cancelled = false;
|
|
100
|
+
this.onCancel = new ResablePromise(() => { });
|
|
100
101
|
this.nestedCancels = [];
|
|
101
102
|
this.cancel = keyIndex.memoize(() => {
|
|
102
103
|
for (const f of this.nestedCancels)
|
|
@@ -104,6 +105,7 @@ class CancelAblePromise extends SettledPromise {
|
|
|
104
105
|
if (this.settled)
|
|
105
106
|
return;
|
|
106
107
|
this.cancelled = true;
|
|
108
|
+
this.onCancel.res();
|
|
107
109
|
if (cancel !== undefined)
|
|
108
110
|
return cancel();
|
|
109
111
|
});
|
|
@@ -16,6 +16,7 @@ export declare class ResablePromise<T = void> extends SettledPromise<T> {
|
|
|
16
16
|
export declare class CancelAblePromise<T = unknown, C = unknown> extends SettledPromise<T> {
|
|
17
17
|
cancelled: boolean;
|
|
18
18
|
cancel: () => void;
|
|
19
|
+
onCancel: Promise<void>;
|
|
19
20
|
private nestedCancels;
|
|
20
21
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void, cancel?: () => C);
|
|
21
22
|
then<TResult1 = T, TResult2 = never>(onfulfilled: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): CancelAblePromise<TResult1 | TResult2>;
|
|
@@ -94,6 +94,7 @@ export class CancelAblePromise extends SettledPromise {
|
|
|
94
94
|
executor(r, rj);
|
|
95
95
|
});
|
|
96
96
|
this.cancelled = false;
|
|
97
|
+
this.onCancel = new ResablePromise(() => { });
|
|
97
98
|
this.nestedCancels = [];
|
|
98
99
|
this.cancel = memoize(() => {
|
|
99
100
|
for (const f of this.nestedCancels)
|
|
@@ -101,6 +102,7 @@ export class CancelAblePromise extends SettledPromise {
|
|
|
101
102
|
if (this.settled)
|
|
102
103
|
return;
|
|
103
104
|
this.cancelled = true;
|
|
105
|
+
this.onCancel.res();
|
|
104
106
|
if (cancel !== undefined)
|
|
105
107
|
return cancel();
|
|
106
108
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "more-proms",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "A collection of additional promise extending classes. Including a (from the outside) ResablePromise, CancelAblePromise and a latestLatent utility function.",
|
|
5
5
|
"main": "./app/dist/esm/moreProms.mjs",
|
|
6
6
|
"types": "./app/dist/esm/moreProms.d.ts",
|