pepka 1.9.5 → 1.10.0
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 -4
- package/dist/bundle.mjs +5 -4
- package/package.json +1 -1
- package/src/common.ts +2 -0
- package/src/utils.ts +2 -3
package/dist/bundle.cjs
CHANGED
|
@@ -96,6 +96,7 @@ function isFunc(s) { return to(s) === 'function'; }
|
|
|
96
96
|
const isStr = (s) => (to(s) === 'string');
|
|
97
97
|
const isObj = (s) => (!isNull(s) && to(s) === 'object');
|
|
98
98
|
const isNil = (s) => (isNull(s) || isUndef(s));
|
|
99
|
+
// TODO: add .then(), .finally() and .catch() to return QPromise.
|
|
99
100
|
class QPromise extends Promise {
|
|
100
101
|
oncancel;
|
|
101
102
|
ff;
|
|
@@ -107,9 +108,7 @@ class QPromise extends Promise {
|
|
|
107
108
|
}
|
|
108
109
|
constructor(fn, oncancel = noop) {
|
|
109
110
|
let _cancel_data = not_assigned;
|
|
110
|
-
super((ff, rj) =>
|
|
111
|
-
_cancel_data = fn(ff, rj);
|
|
112
|
-
});
|
|
111
|
+
super((ff, rj) => _cancel_data = fn(ff, rj));
|
|
113
112
|
this.oncancel = oncancel;
|
|
114
113
|
const set_cb = () => this._cancel_data = _cancel_data;
|
|
115
114
|
// @ts-ignore-next
|
|
@@ -120,6 +119,7 @@ class QPromise extends Promise {
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
122
|
+
const { isNaN } = Number;
|
|
123
123
|
// It's faster that toUpperCase() !
|
|
124
124
|
const caseMap = { u: 'U', b: 'B', n: 'N', s: 'S', f: 'F', o: 'O' };
|
|
125
125
|
const symbol = Symbol();
|
|
@@ -130,7 +130,8 @@ const type = (s) => {
|
|
|
130
130
|
const t = to(s);
|
|
131
131
|
return t === 'object'
|
|
132
132
|
? isNull(s) ? 'Null' : (s.constructor?.name || cap_type(t))
|
|
133
|
-
:
|
|
133
|
+
: t === 'number' && isNaN(s) ? 'NaN'
|
|
134
|
+
: cap_type(t);
|
|
134
135
|
};
|
|
135
136
|
const typeIs = curry2((t, s) => type(s) === t);
|
|
136
137
|
const eq = curry2((a, b) => a === b);
|
package/dist/bundle.mjs
CHANGED
|
@@ -94,6 +94,7 @@ function isFunc(s) { return to(s) === 'function'; }
|
|
|
94
94
|
const isStr = (s) => (to(s) === 'string');
|
|
95
95
|
const isObj = (s) => (!isNull(s) && to(s) === 'object');
|
|
96
96
|
const isNil = (s) => (isNull(s) || isUndef(s));
|
|
97
|
+
// TODO: add .then(), .finally() and .catch() to return QPromise.
|
|
97
98
|
class QPromise extends Promise {
|
|
98
99
|
oncancel;
|
|
99
100
|
ff;
|
|
@@ -105,9 +106,7 @@ class QPromise extends Promise {
|
|
|
105
106
|
}
|
|
106
107
|
constructor(fn, oncancel = noop) {
|
|
107
108
|
let _cancel_data = not_assigned;
|
|
108
|
-
super((ff, rj) =>
|
|
109
|
-
_cancel_data = fn(ff, rj);
|
|
110
|
-
});
|
|
109
|
+
super((ff, rj) => _cancel_data = fn(ff, rj));
|
|
111
110
|
this.oncancel = oncancel;
|
|
112
111
|
const set_cb = () => this._cancel_data = _cancel_data;
|
|
113
112
|
// @ts-ignore-next
|
|
@@ -118,6 +117,7 @@ class QPromise extends Promise {
|
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
|
|
120
|
+
const { isNaN } = Number;
|
|
121
121
|
// It's faster that toUpperCase() !
|
|
122
122
|
const caseMap = { u: 'U', b: 'B', n: 'N', s: 'S', f: 'F', o: 'O' };
|
|
123
123
|
const symbol = Symbol();
|
|
@@ -128,7 +128,8 @@ const type = (s) => {
|
|
|
128
128
|
const t = to(s);
|
|
129
129
|
return t === 'object'
|
|
130
130
|
? isNull(s) ? 'Null' : (s.constructor?.name || cap_type(t))
|
|
131
|
-
:
|
|
131
|
+
: t === 'number' && isNaN(s) ? 'NaN'
|
|
132
|
+
: cap_type(t);
|
|
132
133
|
};
|
|
133
134
|
const typeIs = curry2((t, s) => type(s) === t);
|
|
134
135
|
const eq = curry2((a, b) => a === b);
|
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.
|
|
44
|
+
"version": "1.10.0",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
47
47
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
package/src/common.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { curry2 } from "./curry"
|
|
2
2
|
import { is_typed_arr } from "./internal"
|
|
3
3
|
import { isNull, isStr, to } from "./utils"
|
|
4
|
+
const {isNaN} = Number
|
|
4
5
|
|
|
5
6
|
// It's faster that toUpperCase() !
|
|
6
7
|
const caseMap = { u: 'U', b: 'B', n: 'N', s: 'S', f: 'F', o: 'O' }
|
|
@@ -13,6 +14,7 @@ export const type = (s: any): string => {
|
|
|
13
14
|
const t = to(s)
|
|
14
15
|
return t==='object'
|
|
15
16
|
? isNull(s) ? 'Null' : (s.constructor?.name||cap_type(t))
|
|
17
|
+
: t==='number'&&isNaN(s) ? 'NaN'
|
|
16
18
|
: cap_type(t)
|
|
17
19
|
}
|
|
18
20
|
export const typeIs = curry2((t: string, s: any) => type(s)===t)
|
package/src/utils.ts
CHANGED
|
@@ -17,6 +17,7 @@ export const isStr = <T extends any>(s: T) => (to(s)==='string') as T extends st
|
|
|
17
17
|
export const isObj = <T extends any>(s: T) => (!isNull(s) && to(s)==='object') as T extends AnyObject ? true : false
|
|
18
18
|
export const isNil = <T extends any>(s: T) => (isNull(s) || isUndef(s)) as T extends (null|undefined) ? true : false
|
|
19
19
|
|
|
20
|
+
// TODO: add .then(), .finally() and .catch() to return QPromise.
|
|
20
21
|
export class QPromise<T> extends Promise<T> {
|
|
21
22
|
private ff: AnyFunc
|
|
22
23
|
private _cancel_data: any
|
|
@@ -26,9 +27,7 @@ export class QPromise<T> extends Promise<T> {
|
|
|
26
27
|
}
|
|
27
28
|
constructor(fn: AnyFunc<any, [AnyFunc, AnyFunc, AnyFunc?]>, private oncancel = noop) {
|
|
28
29
|
let _cancel_data: any = not_assigned
|
|
29
|
-
super((ff, rj) =>
|
|
30
|
-
_cancel_data = fn(ff, rj)
|
|
31
|
-
})
|
|
30
|
+
super((ff, rj) => _cancel_data = fn(ff, rj))
|
|
32
31
|
const set_cb = () => this._cancel_data=_cancel_data
|
|
33
32
|
// @ts-ignore-next
|
|
34
33
|
if(_cancel_data!==not_assigned) set_cb()
|