pepka 1.11.1 → 1.12.1
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 +7 -3
- package/dist/bundle.mjs +7 -3
- package/package.json +2 -1
- package/src/quick.ts +6 -4
- package/src/safe.ts +1 -1
- package/test/workbench.html +1 -0
package/dist/bundle.cjs
CHANGED
|
@@ -210,15 +210,19 @@ const qmergeDeepAdd = mergeDeep$1(3);
|
|
|
210
210
|
const qmergeShallow = curry2((o1, o2) => Object.assign(o1, o2));
|
|
211
211
|
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
212
212
|
const qmapKeys = curry2((keyMap, o) => {
|
|
213
|
-
let k, mapped, newKey, newValue;
|
|
213
|
+
let k, mapped, newKey, newValue, swap = {}, inswap;
|
|
214
214
|
for (k in keyMap)
|
|
215
215
|
if (k in o) {
|
|
216
216
|
mapped = keyMap[k];
|
|
217
217
|
[newKey, newValue] = isFunc(mapped)
|
|
218
218
|
? mapped(o[k], k, o)
|
|
219
219
|
: [mapped, o[k]];
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
if (newKey in keyMap)
|
|
221
|
+
swap[newKey] = o[newKey];
|
|
222
|
+
inswap = k in swap;
|
|
223
|
+
if (!isNil(newKey))
|
|
224
|
+
o[newKey] = inswap ? swap[k] : newValue;
|
|
225
|
+
if (!inswap && k !== newKey)
|
|
222
226
|
delete o[k];
|
|
223
227
|
}
|
|
224
228
|
return o;
|
package/dist/bundle.mjs
CHANGED
|
@@ -208,15 +208,19 @@ const qmergeDeepAdd = mergeDeep$1(3);
|
|
|
208
208
|
const qmergeShallow = curry2((o1, o2) => Object.assign(o1, o2));
|
|
209
209
|
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
210
210
|
const qmapKeys = curry2((keyMap, o) => {
|
|
211
|
-
let k, mapped, newKey, newValue;
|
|
211
|
+
let k, mapped, newKey, newValue, swap = {}, inswap;
|
|
212
212
|
for (k in keyMap)
|
|
213
213
|
if (k in o) {
|
|
214
214
|
mapped = keyMap[k];
|
|
215
215
|
[newKey, newValue] = isFunc(mapped)
|
|
216
216
|
? mapped(o[k], k, o)
|
|
217
217
|
: [mapped, o[k]];
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
if (newKey in keyMap)
|
|
219
|
+
swap[newKey] = o[newKey];
|
|
220
|
+
inswap = k in swap;
|
|
221
|
+
if (!isNil(newKey))
|
|
222
|
+
o[newKey] = inswap ? swap[k] : newValue;
|
|
223
|
+
if (!inswap && k !== newKey)
|
|
220
224
|
delete o[k];
|
|
221
225
|
}
|
|
222
226
|
return o;
|
package/package.json
CHANGED
|
@@ -36,12 +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 'npm run dev'",
|
|
39
40
|
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
|
|
40
41
|
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
|
|
41
42
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
42
43
|
"all": "npm run dev && npm run prod"
|
|
43
44
|
},
|
|
44
|
-
"version": "1.
|
|
45
|
+
"version": "1.12.1",
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
47
48
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
package/src/quick.ts
CHANGED
|
@@ -44,20 +44,22 @@ export const qmergeDeepX = mergeDeep(2)
|
|
|
44
44
|
export const qmergeDeepAdd = mergeDeep(3)
|
|
45
45
|
/** @param o1 <- o2 */
|
|
46
46
|
export const qmergeShallow = curry2((o1: AnyObject, o2: AnyObject) => Object.assign(o1, o2))
|
|
47
|
-
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
47
|
+
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } removes a key when null. */
|
|
48
48
|
export const qmapKeys = curry2(
|
|
49
49
|
(
|
|
50
50
|
keyMap: {[oldKey: string]: string | AnyFunc},
|
|
51
51
|
o: AnyObject
|
|
52
52
|
) => {
|
|
53
|
-
let k: string, mapped: string | AnyFunc, newKey: string, newValue: any
|
|
53
|
+
let k: string, mapped: string | AnyFunc, newKey: string, newValue: any, swap: AnyObject = {}, inswap: boolean
|
|
54
54
|
for(k in keyMap) if(k in o) {
|
|
55
55
|
mapped = keyMap[k]
|
|
56
56
|
;[newKey, newValue] = isFunc(mapped)
|
|
57
57
|
? (mapped as AnyFunc)(o[k], k, o)
|
|
58
58
|
: [mapped, o[k]]
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if(newKey in keyMap) swap[newKey] = o[newKey]
|
|
60
|
+
inswap = k in swap
|
|
61
|
+
if(!isNil(newKey)) o[newKey] = inswap ? swap[k] : newValue
|
|
62
|
+
if(!inswap && k !== newKey) delete o[k]
|
|
61
63
|
}
|
|
62
64
|
return o
|
|
63
65
|
}
|
package/src/safe.ts
CHANGED
|
@@ -430,7 +430,7 @@ export const mergeDeepAdd = curry2(
|
|
|
430
430
|
*/
|
|
431
431
|
export const overProp = curry3(
|
|
432
432
|
(prop: string, pipe: AnyFunc, data: any) =>
|
|
433
|
-
|
|
433
|
+
prop in data ? assoc(prop, pipe(data[prop]), data) : data
|
|
434
434
|
)
|
|
435
435
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
436
436
|
export const mapKeys = curry2(
|