pepka 1.12.1 → 1.12.2
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 +10 -4
- package/dist/bundle.d.ts +2 -1
- package/dist/bundle.mjs +10 -4
- package/package.json +3 -2
- package/src/utils.ts +6 -2
package/dist/bundle.cjs
CHANGED
|
@@ -102,15 +102,21 @@ const isSafe = (prop) => !(prop in unsafe_props);
|
|
|
102
102
|
class QPromise extends Promise {
|
|
103
103
|
oncancel;
|
|
104
104
|
ff;
|
|
105
|
+
rj;
|
|
105
106
|
_cancel_data;
|
|
106
107
|
cancel(resolve = false) {
|
|
107
108
|
if (resolve)
|
|
108
|
-
this.ff();
|
|
109
|
+
this.ff?.();
|
|
110
|
+
else
|
|
111
|
+
this.rj?.();
|
|
109
112
|
this.oncancel(this._cancel_data);
|
|
110
113
|
}
|
|
111
114
|
constructor(fn, oncancel = noop) {
|
|
112
115
|
let _cancel_data = not_assigned;
|
|
113
|
-
super((ff, rj) =>
|
|
116
|
+
super((ff, rj) => {
|
|
117
|
+
_cancel_data = fn(ff, rj);
|
|
118
|
+
setTimeout(() => { this.ff = ff; this.rj = rj; });
|
|
119
|
+
});
|
|
114
120
|
this.oncancel = oncancel;
|
|
115
121
|
const set_cb = () => this._cancel_data = _cancel_data;
|
|
116
122
|
// @ts-ignore-next
|
|
@@ -208,7 +214,7 @@ const qmergeDeepX = mergeDeep$1(2);
|
|
|
208
214
|
const qmergeDeepAdd = mergeDeep$1(3);
|
|
209
215
|
/** @param o1 <- o2 */
|
|
210
216
|
const qmergeShallow = curry2((o1, o2) => Object.assign(o1, o2));
|
|
211
|
-
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
217
|
+
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } removes a key when null. */
|
|
212
218
|
const qmapKeys = curry2((keyMap, o) => {
|
|
213
219
|
let k, mapped, newKey, newValue, swap = {}, inswap;
|
|
214
220
|
for (k in keyMap)
|
|
@@ -646,7 +652,7 @@ const mergeDeepAdd = curry2((a, b) => qmergeDeepAdd(clone(a), b));
|
|
|
646
652
|
* @param data any
|
|
647
653
|
* @returns data with prop over pipe.
|
|
648
654
|
*/
|
|
649
|
-
const overProp = curry3((prop, pipe, data) =>
|
|
655
|
+
const overProp = curry3((prop, pipe, data) => prop in data ? assoc(prop, pipe(data[prop]), data) : data);
|
|
650
656
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
651
657
|
const mapKeys = curry2((keyMap, o) => qmapKeys(keyMap, assign({}, o)));
|
|
652
658
|
const zip = curry2((a, b) => map((s, i) => [s, b[i]], a));
|
package/dist/bundle.d.ts
CHANGED
|
@@ -144,7 +144,7 @@ export declare const qmergeShallow: {
|
|
|
144
144
|
(a: AnyObject): (b: AnyObject) => AnyObject;
|
|
145
145
|
(a: AnyObject, b: AnyObject): AnyObject;
|
|
146
146
|
};
|
|
147
|
-
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
147
|
+
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } removes a key when null. */
|
|
148
148
|
export declare const qmapKeys: {
|
|
149
149
|
(a: Placeholder, b: AnyObject): (a: {
|
|
150
150
|
[oldKey: string]: string | AnyFunc;
|
|
@@ -242,6 +242,7 @@ 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;
|
|
245
246
|
private _cancel_data;
|
|
246
247
|
cancel(resolve?: boolean): void;
|
|
247
248
|
constructor(fn: AnyFunc<any, [
|
package/dist/bundle.mjs
CHANGED
|
@@ -100,15 +100,21 @@ const isSafe = (prop) => !(prop in unsafe_props);
|
|
|
100
100
|
class QPromise extends Promise {
|
|
101
101
|
oncancel;
|
|
102
102
|
ff;
|
|
103
|
+
rj;
|
|
103
104
|
_cancel_data;
|
|
104
105
|
cancel(resolve = false) {
|
|
105
106
|
if (resolve)
|
|
106
|
-
this.ff();
|
|
107
|
+
this.ff?.();
|
|
108
|
+
else
|
|
109
|
+
this.rj?.();
|
|
107
110
|
this.oncancel(this._cancel_data);
|
|
108
111
|
}
|
|
109
112
|
constructor(fn, oncancel = noop) {
|
|
110
113
|
let _cancel_data = not_assigned;
|
|
111
|
-
super((ff, rj) =>
|
|
114
|
+
super((ff, rj) => {
|
|
115
|
+
_cancel_data = fn(ff, rj);
|
|
116
|
+
setTimeout(() => { this.ff = ff; this.rj = rj; });
|
|
117
|
+
});
|
|
112
118
|
this.oncancel = oncancel;
|
|
113
119
|
const set_cb = () => this._cancel_data = _cancel_data;
|
|
114
120
|
// @ts-ignore-next
|
|
@@ -206,7 +212,7 @@ const qmergeDeepX = mergeDeep$1(2);
|
|
|
206
212
|
const qmergeDeepAdd = mergeDeep$1(3);
|
|
207
213
|
/** @param o1 <- o2 */
|
|
208
214
|
const qmergeShallow = curry2((o1, o2) => Object.assign(o1, o2));
|
|
209
|
-
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
215
|
+
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } removes a key when null. */
|
|
210
216
|
const qmapKeys = curry2((keyMap, o) => {
|
|
211
217
|
let k, mapped, newKey, newValue, swap = {}, inswap;
|
|
212
218
|
for (k in keyMap)
|
|
@@ -644,7 +650,7 @@ const mergeDeepAdd = curry2((a, b) => qmergeDeepAdd(clone(a), b));
|
|
|
644
650
|
* @param data any
|
|
645
651
|
* @returns data with prop over pipe.
|
|
646
652
|
*/
|
|
647
|
-
const overProp = curry3((prop, pipe, data) =>
|
|
653
|
+
const overProp = curry3((prop, pipe, data) => prop in data ? assoc(prop, pipe(data[prop]), data) : data);
|
|
648
654
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
649
655
|
const mapKeys = curry2((keyMap, o) => qmapKeys(keyMap, assign({}, o)));
|
|
650
656
|
const zip = curry2((a, b) => map((s, i) => [s, b[i]], a));
|
package/package.json
CHANGED
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"lint": "tslint src/*.ts",
|
|
37
37
|
"gentypes": "dts-bundle-generator --no-check --export-referenced-types=false -o dist/bundle.d.ts src/index.ts",
|
|
38
38
|
"dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
|
|
39
|
-
"watch": "nodemon --watch src
|
|
39
|
+
"watch": "nodemon --watch src --ext ts,js --exec \"npm run dev\"",
|
|
40
40
|
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
|
|
41
41
|
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
|
|
42
42
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
43
43
|
"all": "npm run dev && npm run prod"
|
|
44
44
|
},
|
|
45
|
-
"version": "1.12.
|
|
45
|
+
"version": "1.12.2",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@types/node": "^25.5.0",
|
|
51
51
|
"cross-env": "^10.1.0",
|
|
52
52
|
"dts-bundle-generator": "^9.5.1",
|
|
53
|
+
"nodemon": "^3.1.14",
|
|
53
54
|
"rollup": "^4.59.0",
|
|
54
55
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
55
56
|
"ts-node": "^10.9.2",
|
package/src/utils.ts
CHANGED
|
@@ -21,14 +21,18 @@ export const isSafe = (prop: string) => !(prop in unsafe_props)
|
|
|
21
21
|
// TODO: add .then(), .finally() and .catch() to return QPromise.
|
|
22
22
|
export class QPromise<T> extends Promise<T> {
|
|
23
23
|
private ff: AnyFunc
|
|
24
|
+
private rj: AnyFunc
|
|
24
25
|
private _cancel_data: any
|
|
25
26
|
public cancel(resolve = false) {
|
|
26
|
-
if(resolve) this.ff()
|
|
27
|
+
if(resolve) this.ff?.(); else this.rj?.()
|
|
27
28
|
this.oncancel(this._cancel_data)
|
|
28
29
|
}
|
|
29
30
|
constructor(fn: AnyFunc<any, [AnyFunc, AnyFunc, AnyFunc?]>, private oncancel = noop) {
|
|
30
31
|
let _cancel_data: any = not_assigned
|
|
31
|
-
super((ff, rj) =>
|
|
32
|
+
super((ff, rj) => {
|
|
33
|
+
_cancel_data = fn(ff, rj)
|
|
34
|
+
setTimeout(() => {this.ff = ff; this.rj = rj})
|
|
35
|
+
})
|
|
32
36
|
const set_cb = () => this._cancel_data=_cancel_data
|
|
33
37
|
// @ts-ignore-next
|
|
34
38
|
if(_cancel_data!==not_assigned) set_cb()
|