pepka 1.9.3 → 1.9.5
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.
- package/dist/bundle.cjs +5 -11
- package/dist/bundle.d.ts +0 -1
- package/dist/bundle.mjs +5 -11
- package/package.json +1 -1
- package/src/utils.ts +5 -10
package/dist/bundle.cjs
CHANGED
|
@@ -86,6 +86,7 @@ const startsWithWith = (comparator) => curry2((start, s) => {
|
|
|
86
86
|
const undef = undefined;
|
|
87
87
|
const nul = null;
|
|
88
88
|
const inf = Infinity;
|
|
89
|
+
const not_assigned = Symbol();
|
|
89
90
|
const to = (s) => typeof s;
|
|
90
91
|
const isNull = (s) => (s === nul);
|
|
91
92
|
const isUndef = (s) => (s === undef);
|
|
@@ -98,28 +99,21 @@ const isNil = (s) => (isNull(s) || isUndef(s));
|
|
|
98
99
|
class QPromise extends Promise {
|
|
99
100
|
oncancel;
|
|
100
101
|
ff;
|
|
101
|
-
rj;
|
|
102
102
|
_cancel_data;
|
|
103
103
|
cancel(resolve = false) {
|
|
104
104
|
if (resolve)
|
|
105
105
|
this.ff();
|
|
106
|
-
|
|
107
|
-
super.catch(noop);
|
|
108
|
-
this.rj('canceled');
|
|
109
|
-
this.oncancel(this._cancel_data);
|
|
110
|
-
}
|
|
106
|
+
this.oncancel(this._cancel_data);
|
|
111
107
|
}
|
|
112
108
|
constructor(fn, oncancel = noop) {
|
|
113
|
-
let
|
|
109
|
+
let _cancel_data = not_assigned;
|
|
114
110
|
super((ff, rj) => {
|
|
115
|
-
_ff = ff;
|
|
116
|
-
_rj = rj;
|
|
117
111
|
_cancel_data = fn(ff, rj);
|
|
118
112
|
});
|
|
119
113
|
this.oncancel = oncancel;
|
|
120
|
-
const set_cb = () =>
|
|
114
|
+
const set_cb = () => this._cancel_data = _cancel_data;
|
|
121
115
|
// @ts-ignore-next
|
|
122
|
-
if (
|
|
116
|
+
if (_cancel_data !== not_assigned)
|
|
123
117
|
set_cb();
|
|
124
118
|
else
|
|
125
119
|
setTimeout(set_cb);
|
package/dist/bundle.d.ts
CHANGED
|
@@ -242,7 +242,6 @@ export declare const isNil: <T extends any>(s: T) => T extends (null | undefined
|
|
|
242
242
|
export declare class QPromise<T> extends Promise<T> {
|
|
243
243
|
private oncancel;
|
|
244
244
|
private ff;
|
|
245
|
-
private rj;
|
|
246
245
|
private _cancel_data;
|
|
247
246
|
cancel(resolve?: boolean): void;
|
|
248
247
|
constructor(fn: AnyFunc<any, [
|
package/dist/bundle.mjs
CHANGED
|
@@ -84,6 +84,7 @@ const startsWithWith = (comparator) => curry2((start, s) => {
|
|
|
84
84
|
const undef = undefined;
|
|
85
85
|
const nul = null;
|
|
86
86
|
const inf = Infinity;
|
|
87
|
+
const not_assigned = Symbol();
|
|
87
88
|
const to = (s) => typeof s;
|
|
88
89
|
const isNull = (s) => (s === nul);
|
|
89
90
|
const isUndef = (s) => (s === undef);
|
|
@@ -96,28 +97,21 @@ const isNil = (s) => (isNull(s) || isUndef(s));
|
|
|
96
97
|
class QPromise extends Promise {
|
|
97
98
|
oncancel;
|
|
98
99
|
ff;
|
|
99
|
-
rj;
|
|
100
100
|
_cancel_data;
|
|
101
101
|
cancel(resolve = false) {
|
|
102
102
|
if (resolve)
|
|
103
103
|
this.ff();
|
|
104
|
-
|
|
105
|
-
super.catch(noop);
|
|
106
|
-
this.rj('canceled');
|
|
107
|
-
this.oncancel(this._cancel_data);
|
|
108
|
-
}
|
|
104
|
+
this.oncancel(this._cancel_data);
|
|
109
105
|
}
|
|
110
106
|
constructor(fn, oncancel = noop) {
|
|
111
|
-
let
|
|
107
|
+
let _cancel_data = not_assigned;
|
|
112
108
|
super((ff, rj) => {
|
|
113
|
-
_ff = ff;
|
|
114
|
-
_rj = rj;
|
|
115
109
|
_cancel_data = fn(ff, rj);
|
|
116
110
|
});
|
|
117
111
|
this.oncancel = oncancel;
|
|
118
|
-
const set_cb = () =>
|
|
112
|
+
const set_cb = () => this._cancel_data = _cancel_data;
|
|
119
113
|
// @ts-ignore-next
|
|
120
|
-
if (
|
|
114
|
+
if (_cancel_data !== not_assigned)
|
|
121
115
|
set_cb();
|
|
122
116
|
else
|
|
123
117
|
setTimeout(set_cb);
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
42
42
|
"all": "npm run dev && npm run prod"
|
|
43
43
|
},
|
|
44
|
-
"version": "1.9.
|
|
44
|
+
"version": "1.9.5",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
47
47
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
package/src/utils.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AnyFunc, AnyObject } from "./types"
|
|
|
4
4
|
export const undef = undefined
|
|
5
5
|
export const nul = null
|
|
6
6
|
export const inf = Infinity
|
|
7
|
+
export const not_assigned = Symbol()
|
|
7
8
|
export const to = (s: any) => typeof s
|
|
8
9
|
export const isNull = <T extends any>(s: T) => (s===nul) as T extends null ? true : false
|
|
9
10
|
export const isUndef = <T extends any>(s: T) => (s===undef) as T extends undefined ? true : false
|
|
@@ -18,25 +19,19 @@ export const isNil = <T extends any>(s: T) => (isNull(s) || isUndef(s)) as T ext
|
|
|
18
19
|
|
|
19
20
|
export class QPromise<T> extends Promise<T> {
|
|
20
21
|
private ff: AnyFunc
|
|
21
|
-
private rj: AnyFunc
|
|
22
22
|
private _cancel_data: any
|
|
23
23
|
public cancel(resolve = false) {
|
|
24
24
|
if(resolve) this.ff()
|
|
25
|
-
|
|
26
|
-
super.catch(noop)
|
|
27
|
-
this.rj('canceled')
|
|
28
|
-
this.oncancel(this._cancel_data)
|
|
29
|
-
}
|
|
25
|
+
this.oncancel(this._cancel_data)
|
|
30
26
|
}
|
|
31
27
|
constructor(fn: AnyFunc<any, [AnyFunc, AnyFunc, AnyFunc?]>, private oncancel = noop) {
|
|
32
|
-
let
|
|
28
|
+
let _cancel_data: any = not_assigned
|
|
33
29
|
super((ff, rj) => {
|
|
34
|
-
_ff=ff; _rj=rj
|
|
35
30
|
_cancel_data = fn(ff, rj)
|
|
36
31
|
})
|
|
37
|
-
const set_cb = () =>
|
|
32
|
+
const set_cb = () => this._cancel_data=_cancel_data
|
|
38
33
|
// @ts-ignore-next
|
|
39
|
-
if(
|
|
34
|
+
if(_cancel_data!==not_assigned) set_cb()
|
|
40
35
|
else setTimeout(set_cb)
|
|
41
36
|
}
|
|
42
37
|
}
|