datum-merge 1.1.0 → 1.3.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/README.md +14 -3
- package/dist/cjs/datum-utils.js +32 -24
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/merge-conf.js +1 -2
- package/dist/cjs/patch-low.js +37 -14
- package/dist/dts/datum-utils.d.ts +2 -2
- package/dist/dts/datum-utils.d.ts.map +1 -1
- package/dist/dts/index.d.ts +2 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/merge-conf.d.ts.map +1 -1
- package/dist/dts/patch-low.d.ts +5 -4
- package/dist/dts/patch-low.d.ts.map +1 -1
- package/dist/esm/datum-utils.js +30 -22
- package/dist/esm/index.js +2 -1
- package/dist/esm/merge-conf.js +2 -3
- package/dist/esm/patch-low.js +34 -12
- package/dist/umd/datum-merge.min.js +1 -1
- package/dist/umd/datum-merge.min.js.map +3 -3
- package/package.json +6 -6
- package/src/datum-utils.ts +35 -26
- package/src/diff-lib/README.md +9 -2
- package/src/diff-lib/package-lock.json +181 -123
- package/src/diff-lib/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/merge-conf.ts +2 -3
- package/src/patch-low.ts +41 -15
package/README.md
CHANGED
|
@@ -52,13 +52,22 @@ const conf: MergeConfig = {
|
|
|
52
52
|
vector: UpdateCode.XM,
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
|
-
const diff = customMerge(target, source, conf);
|
|
55
|
+
const diff: Partial<T> = customMerge<T>(target, source, conf);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Reversible deep merge with changelog in json-patch format:
|
|
59
|
+
```
|
|
60
|
+
import { customMergePatch, MergeResult, revertPatchLog } from "datum-merge";
|
|
61
|
+
const conf = { scalar: "I", vector: "XM", nested: "B" };
|
|
62
|
+
const patch: MergeResult[] = customMergePatch(target, source, conf);
|
|
63
|
+
const changed = revertPatchLog(patch, target);
|
|
64
|
+
applyPatchLog(patch, anotherTarget);
|
|
56
65
|
```
|
|
57
66
|
---
|
|
58
67
|
|
|
59
68
|
## Upcoming Features
|
|
60
69
|
|
|
61
|
-
1. publish
|
|
70
|
+
1. publish diff module as a standalone package ([available](/src/diff-lib/README.md)).
|
|
62
71
|
|
|
63
72
|
2. formalize config schema for deeply nested objects (for v1).
|
|
64
73
|
|
|
@@ -68,6 +77,8 @@ const diff = customMerge(target, source, conf);
|
|
|
68
77
|
|
|
69
78
|
5. support merging for top level arrays or primitives.
|
|
70
79
|
|
|
80
|
+
6. better anti-diff function that retains deep similarities.
|
|
81
|
+
|
|
71
82
|
Code contributions are welcome via issues and pull requests.
|
|
72
83
|
|
|
73
84
|
---
|
|
@@ -110,6 +121,6 @@ Applying the merge results in one of these transitions per primitive value in th
|
|
|
110
121
|
| `add` | new / insert | I | `null <-- non-null` |
|
|
111
122
|
| `replace` | edit / update | H | `non-null <-- non-null` |
|
|
112
123
|
| `remove` | unset / delete | D | `non-null <-- null` |
|
|
113
|
-
| `test` | noop / skip / ignore
|
|
124
|
+
| `test` | noop / skip / ignore | N | `null <-- null` or `non-null == non-null` |
|
|
114
125
|
|
|
115
126
|
---
|
package/dist/cjs/datum-utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.selectObjKeys = exports.getGlobKeys = exports.
|
|
6
|
+
exports.selectObjKeys = exports.getGlobKeys = exports.fastGlobMatch = exports.areArraysEqual = exports.toUniqueArray = exports.deepClone = exports.deepEqualsPath = exports.deepEquals = exports.createValueKeys = exports.getObjectKeys = void 0;
|
|
7
7
|
const lodash_es_1 = require("lodash-es");
|
|
8
8
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
9
9
|
function getObjectKeys(obj, excludeKeys, includeKeys) {
|
|
@@ -27,6 +27,8 @@ function createValueKeys(keys, value) {
|
|
|
27
27
|
}
|
|
28
28
|
exports.createValueKeys = createValueKeys;
|
|
29
29
|
function deepEquals(lhs, rhs) {
|
|
30
|
+
if (lhs === rhs)
|
|
31
|
+
return true;
|
|
30
32
|
return (0, fast_deep_equal_1.default)(lhs, rhs);
|
|
31
33
|
}
|
|
32
34
|
exports.deepEquals = deepEquals;
|
|
@@ -57,31 +59,37 @@ function areArraysEqual(arr1, arr2) {
|
|
|
57
59
|
return true;
|
|
58
60
|
}
|
|
59
61
|
exports.areArraysEqual = areArraysEqual;
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
includeKeys.push(label);
|
|
79
|
-
}
|
|
80
|
-
else if (globPats.findIndex((r) => r.test(label)) >= 0) {
|
|
81
|
-
includeKeys.push(label);
|
|
62
|
+
function fastGlobMatch(glob, text) {
|
|
63
|
+
if (!glob.includes("*"))
|
|
64
|
+
return text === glob;
|
|
65
|
+
if (glob === "*")
|
|
66
|
+
return typeof text === "string";
|
|
67
|
+
const globParts = glob.split(/\*+/g, -1);
|
|
68
|
+
const partsLen = globParts.length;
|
|
69
|
+
if (partsLen === 0)
|
|
70
|
+
return !text;
|
|
71
|
+
if (partsLen === 1)
|
|
72
|
+
return text === globParts[0];
|
|
73
|
+
if (!text.startsWith(globParts[0]))
|
|
74
|
+
return false;
|
|
75
|
+
let textIdx = globParts[0].length;
|
|
76
|
+
for (let i = 1; i < partsLen - 1; i++) {
|
|
77
|
+
const nextIdx = text.indexOf(globParts[i], textIdx);
|
|
78
|
+
if (nextIdx < 0) {
|
|
79
|
+
return false;
|
|
82
80
|
}
|
|
81
|
+
textIdx = nextIdx + globParts[i].length;
|
|
82
|
+
continue;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
if (!text.endsWith(globParts[partsLen - 1]))
|
|
85
|
+
return false;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
exports.fastGlobMatch = fastGlobMatch;
|
|
89
|
+
function getGlobKeys(obj, inclPats = ["*"], exclPats) {
|
|
90
|
+
return Object.keys(obj)
|
|
91
|
+
.filter((k) => !inclPats || inclPats.some((g) => fastGlobMatch(g, k)))
|
|
92
|
+
.filter((k) => !(exclPats === null || exclPats === void 0 ? void 0 : exclPats.length) || !exclPats.some((g) => fastGlobMatch(g, k)));
|
|
85
93
|
}
|
|
86
94
|
exports.getGlobKeys = getGlobKeys;
|
|
87
95
|
function selectObjKeys(obj, includeKeys) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.deepDiff = exports.mergeDiff = exports.merge = exports.selectPathCode = exports.deepMergeLog = exports.bypassMergePatch = exports.customMergePatch = exports.bypassMerge = exports.immutableCustomMerge = exports.customMerge = exports.fillUpdateCodes = exports.immutableDetailMerge = exports.detailMerge = exports.patchFromMerge = exports.diffFromMerge = exports.immutableDeepMerge = exports.deepMerge = exports.immutableMerge = exports.shallowMerge = exports.updateCodeInfo = exports.MC = exports.UpdateCode = exports.
|
|
17
|
+
exports.deepDiff = exports.mergeDiff = exports.merge = exports.selectPathCode = exports.deepMergeLog = exports.bypassMergePatch = exports.customMergePatch = exports.bypassMerge = exports.immutableCustomMerge = exports.customMerge = exports.fillUpdateCodes = exports.immutableDetailMerge = exports.detailMerge = exports.patchFromMerge = exports.diffFromMerge = exports.immutableDeepMerge = exports.deepMerge = exports.immutableMerge = exports.shallowMerge = exports.updateCodeInfo = exports.MC = exports.UpdateCode = exports.getPointerValue = exports.immutablePatch = exports.revertPatchLog = exports.applyPatchLog = exports.deepPatchLog = exports.diffToPatchLog = exports.unflattenObject = exports.flattenObject = exports.deepDiffFlat = exports.antiDiffTyped = exports.deepDiffTyped = exports.deepDiffLow = exports.deepClone = exports.deepEquals = void 0;
|
|
18
18
|
var datum_utils_1 = require("./datum-utils");
|
|
19
19
|
Object.defineProperty(exports, "deepEquals", { enumerable: true, get: function () { return datum_utils_1.deepEquals; } });
|
|
20
20
|
var datum_utils_2 = require("./datum-utils");
|
|
@@ -35,7 +35,9 @@ Object.defineProperty(exports, "deepPatchLog", { enumerable: true, get: function
|
|
|
35
35
|
var patch_low_2 = require("./patch-low");
|
|
36
36
|
Object.defineProperty(exports, "applyPatchLog", { enumerable: true, get: function () { return patch_low_2.applyPatchLog; } });
|
|
37
37
|
Object.defineProperty(exports, "revertPatchLog", { enumerable: true, get: function () { return patch_low_2.revertPatchLog; } });
|
|
38
|
-
|
|
38
|
+
var patch_low_3 = require("./patch-low");
|
|
39
|
+
Object.defineProperty(exports, "immutablePatch", { enumerable: true, get: function () { return patch_low_3.immutablePatch; } });
|
|
40
|
+
Object.defineProperty(exports, "getPointerValue", { enumerable: true, get: function () { return patch_low_3.getPointerValue; } });
|
|
39
41
|
var merge_low_1 = require("./merge-low");
|
|
40
42
|
Object.defineProperty(exports, "UpdateCode", { enumerable: true, get: function () { return merge_low_1.UpdateCode; } });
|
|
41
43
|
var merge_low_2 = require("./merge-low");
|
package/dist/cjs/merge-conf.js
CHANGED
|
@@ -113,7 +113,6 @@ const fillUpdateCodes = (source, mergeConf, blockUnset = false, excludeKeys) =>
|
|
|
113
113
|
const globKeys = (0, datum_utils_1.getObjectKeys)(mergeConf)
|
|
114
114
|
.filter((s) => s.includes("*"))
|
|
115
115
|
.sort((s1, s2) => s2.length - s1.length);
|
|
116
|
-
const globPats = globKeys.map((g) => (0, datum_utils_1.createGlobRegex)(g));
|
|
117
116
|
const mergeCodes = {};
|
|
118
117
|
const sourceKeys = (0, datum_utils_1.getObjectKeys)(source);
|
|
119
118
|
for (const srcLabel of sourceKeys) {
|
|
@@ -135,7 +134,7 @@ const fillUpdateCodes = (source, mergeConf, blockUnset = false, excludeKeys) =>
|
|
|
135
134
|
mergeCodes[srcLabel] = (0, exports.fillUpdateCodes)(srcValue, Object.assign(Object.assign({}, deepConf), labelConf), blockUnset);
|
|
136
135
|
continue;
|
|
137
136
|
}
|
|
138
|
-
const globIndex =
|
|
137
|
+
const globIndex = globKeys.findIndex((g) => (0, datum_utils_1.fastGlobMatch)(g, srcLabel));
|
|
139
138
|
if (globIndex >= 0) {
|
|
140
139
|
const globConf = mergeConf[globKeys[globIndex]];
|
|
141
140
|
if ((0, type_utils_1.isString)(globConf)) {
|
package/dist/cjs/patch-low.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getPointerValue = exports.asLodashPath = exports.immutablePatch = exports.revertPatchLog = exports.applyPatchLog = exports.deepPatchLog = exports.diffToPatchLog = void 0;
|
|
4
4
|
const lodash_es_1 = require("lodash-es");
|
|
5
|
+
const datum_utils_1 = require("./datum-utils");
|
|
5
6
|
const diff_high_1 = require("./diff-high");
|
|
6
7
|
function diffToPatchLog(differences, storePrev = false) {
|
|
7
8
|
var _a, _b, _c;
|
|
@@ -41,36 +42,58 @@ function deepPatchLog(lhsObj, rhsObj, orderInd = false, storePrev = false) {
|
|
|
41
42
|
}
|
|
42
43
|
exports.deepPatchLog = deepPatchLog;
|
|
43
44
|
;
|
|
44
|
-
function applyPatchLog(patchLog, target
|
|
45
|
-
if (!patchLog)
|
|
46
|
-
return
|
|
45
|
+
function applyPatchLog(patchLog, target) {
|
|
46
|
+
if (!target || !(patchLog === null || patchLog === void 0 ? void 0 : patchLog.length))
|
|
47
|
+
return false;
|
|
48
|
+
let changed = false;
|
|
47
49
|
for (const patchItem of patchLog) {
|
|
48
50
|
const difPath = asLodashPath(patchItem.path);
|
|
51
|
+
if (patchItem.op === "test")
|
|
52
|
+
continue;
|
|
49
53
|
if (patchItem.op === "remove") {
|
|
50
|
-
(0, lodash_es_1.unset)(target, difPath);
|
|
54
|
+
changed = (0, lodash_es_1.unset)(target, difPath) || changed;
|
|
55
|
+
continue;
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
const targetVal = (0, lodash_es_1.get)(target, difPath);
|
|
58
|
+
if (!targetVal && !patchItem.value)
|
|
59
|
+
continue;
|
|
60
|
+
if (!targetVal || !(0, datum_utils_1.deepEquals)(targetVal, patchItem.value)) {
|
|
53
61
|
(0, lodash_es_1.set)(target, difPath, patchItem.value);
|
|
62
|
+
changed = true;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
|
-
return
|
|
65
|
+
return changed;
|
|
57
66
|
}
|
|
58
67
|
exports.applyPatchLog = applyPatchLog;
|
|
59
68
|
function revertPatchLog(patchLog, target) {
|
|
60
|
-
if (!patchLog)
|
|
61
|
-
return
|
|
69
|
+
if (!target || !(patchLog === null || patchLog === void 0 ? void 0 : patchLog.length))
|
|
70
|
+
return false;
|
|
71
|
+
let changed = false;
|
|
62
72
|
for (const patchItem of patchLog) {
|
|
63
73
|
const difPath = asLodashPath(patchItem.path);
|
|
64
74
|
if (patchItem.op === "add") {
|
|
65
|
-
(0, lodash_es_1.unset)(target, difPath);
|
|
75
|
+
changed = (0, lodash_es_1.unset)(target, difPath) || changed;
|
|
66
76
|
}
|
|
67
|
-
else {
|
|
77
|
+
else if (patchItem.op !== "test") {
|
|
68
78
|
(0, lodash_es_1.set)(target, difPath, patchItem.prev);
|
|
79
|
+
changed = true;
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
|
-
return
|
|
82
|
+
return changed;
|
|
72
83
|
}
|
|
73
84
|
exports.revertPatchLog = revertPatchLog;
|
|
85
|
+
function immutablePatch(target, patchSrc, patchDir) {
|
|
86
|
+
const targetCopy = (0, datum_utils_1.deepClone)(target !== null && target !== void 0 ? target : {});
|
|
87
|
+
if (patchDir === "revert") {
|
|
88
|
+
revertPatchLog(patchSrc, targetCopy);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
applyPatchLog(patchSrc, targetCopy);
|
|
92
|
+
}
|
|
93
|
+
return targetCopy;
|
|
94
|
+
}
|
|
95
|
+
exports.immutablePatch = immutablePatch;
|
|
96
|
+
;
|
|
74
97
|
function escapePathPart(path) {
|
|
75
98
|
if (typeof path === 'number')
|
|
76
99
|
return path.toString();
|
|
@@ -95,8 +118,8 @@ function asLodashPath(pointer) {
|
|
|
95
118
|
return !(parts === null || parts === void 0 ? void 0 : parts.length) ? [] : (0, lodash_es_1.toPath)(parts.join("."));
|
|
96
119
|
}
|
|
97
120
|
exports.asLodashPath = asLodashPath;
|
|
98
|
-
function
|
|
121
|
+
function getPointerValue(document, pointer) {
|
|
99
122
|
return pointer === "" ? document
|
|
100
123
|
: (0, lodash_es_1.get)(document, asLodashPath(pointer));
|
|
101
124
|
}
|
|
102
|
-
exports.
|
|
125
|
+
exports.getPointerValue = getPointerValue;
|
|
@@ -7,7 +7,7 @@ export declare function deepEqualsPath(lhs: any, rhs: any, atPath: string): bool
|
|
|
7
7
|
export declare function deepClone<T = any>(val: T): T;
|
|
8
8
|
export declare function toUniqueArray<T>(arr: T[]): T[];
|
|
9
9
|
export declare function areArraysEqual<T>(arr1: T[] | undefined, arr2: T[] | undefined): boolean;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function getGlobKeys(obj: any,
|
|
10
|
+
export declare function fastGlobMatch(glob: string, text: string): boolean;
|
|
11
|
+
export declare function getGlobKeys(obj: any, inclPats?: string[], exclPats?: string[]): string[];
|
|
12
12
|
export declare function selectObjKeys<T extends object>(obj: T, includeKeys: string[]): Partial<T>;
|
|
13
13
|
//# sourceMappingURL=datum-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datum-utils.d.ts","sourceRoot":"","sources":["../../src/datum-utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CACzB,GAAG,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,WAAW,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM,EAAE,CAaV;AAED,wBAAgB,eAAe,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,CAAC,GACT;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAEtB;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"datum-utils.d.ts","sourceRoot":"","sources":["../../src/datum-utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CACzB,GAAG,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,WAAW,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM,EAAE,CAaV;AAED,wBAAgB,eAAe,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,CAAC,GACT;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAEtB;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAItD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAE5C;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE9C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC5B,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,EACrB,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,GACtB,OAAO,CAaT;AAID,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb,OAAO,CAyBT;AAED,wBAAgB,WAAW,CACvB,GAAG,EAAE,GAAG,EACR,QAAQ,GAAE,MAAM,EAAU,EAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GACpB,MAAM,EAAE,CAIV;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC1C,GAAG,EAAE,CAAC,EACN,WAAW,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,CAAC,CAAC,CAMZ"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export { deepDiffFlat } from "./diff-high";
|
|
|
6
6
|
export { flattenObject, unflattenObject } from "./diff-high";
|
|
7
7
|
export { type PatchResult } from "./patch-low";
|
|
8
8
|
export { diffToPatchLog, deepPatchLog } from "./patch-low";
|
|
9
|
-
export { applyPatchLog, revertPatchLog
|
|
9
|
+
export { applyPatchLog, revertPatchLog } from "./patch-low";
|
|
10
|
+
export { immutablePatch, getPointerValue } from "./patch-low";
|
|
10
11
|
export { UpdateCode } from "./merge-low";
|
|
11
12
|
export { UpdateCode as MC } from "./merge-low";
|
|
12
13
|
export { type MergeCode } from "./merge-low";
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,O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B,QAAQ,GAAE,OAAe,GAC1B,GAAG,CAOL;AAWD,eAAO,MAAM,eAAe,WAChB,GAAG,aACA,WAAW,GAAG,SAAS,eACtB,OAAO,gBACL,MAAM,EAAE,KACvB,YAmEF,CAAA"}
|
package/dist/dts/patch-low.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Diff } from "./diff-lib/deep-diff";
|
|
2
2
|
export type PatchResult<T = any> = {
|
|
3
3
|
path: string;
|
|
4
|
-
op: "add" | "remove" | "replace";
|
|
4
|
+
op: "add" | "remove" | "replace" | "test";
|
|
5
5
|
value?: Readonly<T>;
|
|
6
6
|
prev?: any;
|
|
7
7
|
};
|
|
@@ -11,8 +11,9 @@ export declare function deepPatchLog(lhsObj: {
|
|
|
11
11
|
}, rhsObj: {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
}, orderInd?: boolean, storePrev?: boolean): PatchResult[];
|
|
14
|
-
export declare function applyPatchLog(patchLog: PatchResult[], target
|
|
15
|
-
export declare function revertPatchLog(patchLog: PatchResult[], target: object):
|
|
14
|
+
export declare function applyPatchLog(patchLog: PatchResult[], target: object): boolean;
|
|
15
|
+
export declare function revertPatchLog(patchLog: PatchResult[], target: object): boolean;
|
|
16
|
+
export declare function immutablePatch(target: object, patchSrc: PatchResult[], patchDir?: "apply" | "revert"): object;
|
|
16
17
|
export declare function asLodashPath(pointer: string): string[];
|
|
17
|
-
export declare function
|
|
18
|
+
export declare function getPointerValue(document: any, pointer: string): any;
|
|
18
19
|
//# sourceMappingURL=patch-low.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-low.d.ts","sourceRoot":"","sources":["../../src/patch-low.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"patch-low.d.ts","sourceRoot":"","sources":["../../src/patch-low.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,MAAM,MAAM,WAAW,CAAC,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
export function deepEquals(lhs, rhs) {
|
|
22
|
+
if (lhs === rhs)
|
|
23
|
+
return true;
|
|
22
24
|
return equal(lhs, rhs);
|
|
23
25
|
}
|
|
24
26
|
export function deepEqualsPath(lhs, rhs, atPath) {
|
|
@@ -44,30 +46,36 @@ export function areArraysEqual(arr1, arr2) {
|
|
|
44
46
|
}
|
|
45
47
|
return true;
|
|
46
48
|
}
|
|
47
|
-
export function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else if (globPats.findIndex((r) => r.test(label)) >= 0) {
|
|
67
|
-
includeKeys.push(label);
|
|
49
|
+
export function fastGlobMatch(glob, text) {
|
|
50
|
+
if (!glob.includes("*"))
|
|
51
|
+
return text === glob;
|
|
52
|
+
if (glob === "*")
|
|
53
|
+
return typeof text === "string";
|
|
54
|
+
const globParts = glob.split(/\*+/g, -1);
|
|
55
|
+
const partsLen = globParts.length;
|
|
56
|
+
if (partsLen === 0)
|
|
57
|
+
return !text;
|
|
58
|
+
if (partsLen === 1)
|
|
59
|
+
return text === globParts[0];
|
|
60
|
+
if (!text.startsWith(globParts[0]))
|
|
61
|
+
return false;
|
|
62
|
+
let textIdx = globParts[0].length;
|
|
63
|
+
for (let i = 1; i < partsLen - 1; i++) {
|
|
64
|
+
const nextIdx = text.indexOf(globParts[i], textIdx);
|
|
65
|
+
if (nextIdx < 0) {
|
|
66
|
+
return false;
|
|
68
67
|
}
|
|
68
|
+
textIdx = nextIdx + globParts[i].length;
|
|
69
|
+
continue;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
if (!text.endsWith(globParts[partsLen - 1]))
|
|
72
|
+
return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
export function getGlobKeys(obj, inclPats = ["*"], exclPats) {
|
|
76
|
+
return Object.keys(obj)
|
|
77
|
+
.filter((k) => !inclPats || inclPats.some((g) => fastGlobMatch(g, k)))
|
|
78
|
+
.filter((k) => !(exclPats === null || exclPats === void 0 ? void 0 : exclPats.length) || !exclPats.some((g) => fastGlobMatch(g, k)));
|
|
71
79
|
}
|
|
72
80
|
export function selectObjKeys(obj, includeKeys) {
|
|
73
81
|
if (!(includeKeys === null || includeKeys === void 0 ? void 0 : includeKeys.length))
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { deepDiffTyped, antiDiffTyped } from "./diff-high";
|
|
|
5
5
|
export { deepDiffFlat } from "./diff-high";
|
|
6
6
|
export { flattenObject, unflattenObject } from "./diff-high";
|
|
7
7
|
export { diffToPatchLog, deepPatchLog } from "./patch-low";
|
|
8
|
-
export { applyPatchLog, revertPatchLog
|
|
8
|
+
export { applyPatchLog, revertPatchLog } from "./patch-low";
|
|
9
|
+
export { immutablePatch, getPointerValue } from "./patch-low";
|
|
9
10
|
export { UpdateCode } from "./merge-low";
|
|
10
11
|
export { UpdateCode as MC } from "./merge-low";
|
|
11
12
|
export { updateCodeInfo } from "./merge-high";
|
package/dist/esm/merge-conf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArrayOfAny, emptyObject, isNullish, isObject, isString } from "./type-utils";
|
|
2
|
-
import {
|
|
2
|
+
import { deepClone, fastGlobMatch, getObjectKeys, selectObjKeys } from "./datum-utils";
|
|
3
3
|
import { deepDiffTyped } from "./diff-high";
|
|
4
4
|
import { UpdateCode, mergeScalarField, mergeVectorField } from "./merge-low";
|
|
5
5
|
import { updateCodeInfo } from "./merge-high";
|
|
@@ -104,7 +104,6 @@ export const fillUpdateCodes = (source, mergeConf, blockUnset = false, excludeKe
|
|
|
104
104
|
const globKeys = getObjectKeys(mergeConf)
|
|
105
105
|
.filter((s) => s.includes("*"))
|
|
106
106
|
.sort((s1, s2) => s2.length - s1.length);
|
|
107
|
-
const globPats = globKeys.map((g) => createGlobRegex(g));
|
|
108
107
|
const mergeCodes = {};
|
|
109
108
|
const sourceKeys = getObjectKeys(source);
|
|
110
109
|
for (const srcLabel of sourceKeys) {
|
|
@@ -126,7 +125,7 @@ export const fillUpdateCodes = (source, mergeConf, blockUnset = false, excludeKe
|
|
|
126
125
|
mergeCodes[srcLabel] = fillUpdateCodes(srcValue, Object.assign(Object.assign({}, deepConf), labelConf), blockUnset);
|
|
127
126
|
continue;
|
|
128
127
|
}
|
|
129
|
-
const globIndex =
|
|
128
|
+
const globIndex = globKeys.findIndex((g) => fastGlobMatch(g, srcLabel));
|
|
130
129
|
if (globIndex >= 0) {
|
|
131
130
|
const globConf = mergeConf[globKeys[globIndex]];
|
|
132
131
|
if (isString(globConf)) {
|
package/dist/esm/patch-low.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { get, set, toPath, unset } from "lodash-es";
|
|
2
|
+
import { deepClone, deepEquals } from "./datum-utils";
|
|
2
3
|
import { deepDiffLow } from "./diff-high";
|
|
3
4
|
export function diffToPatchLog(differences, storePrev = false) {
|
|
4
5
|
var _a, _b, _c;
|
|
@@ -36,34 +37,55 @@ export function deepPatchLog(lhsObj, rhsObj, orderInd = false, storePrev = false
|
|
|
36
37
|
return !differences ? [] : diffToPatchLog(differences, storePrev);
|
|
37
38
|
}
|
|
38
39
|
;
|
|
39
|
-
export function applyPatchLog(patchLog, target
|
|
40
|
-
if (!patchLog)
|
|
41
|
-
return
|
|
40
|
+
export function applyPatchLog(patchLog, target) {
|
|
41
|
+
if (!target || !(patchLog === null || patchLog === void 0 ? void 0 : patchLog.length))
|
|
42
|
+
return false;
|
|
43
|
+
let changed = false;
|
|
42
44
|
for (const patchItem of patchLog) {
|
|
43
45
|
const difPath = asLodashPath(patchItem.path);
|
|
46
|
+
if (patchItem.op === "test")
|
|
47
|
+
continue;
|
|
44
48
|
if (patchItem.op === "remove") {
|
|
45
|
-
unset(target, difPath);
|
|
49
|
+
changed = unset(target, difPath) || changed;
|
|
50
|
+
continue;
|
|
46
51
|
}
|
|
47
|
-
|
|
52
|
+
const targetVal = get(target, difPath);
|
|
53
|
+
if (!targetVal && !patchItem.value)
|
|
54
|
+
continue;
|
|
55
|
+
if (!targetVal || !deepEquals(targetVal, patchItem.value)) {
|
|
48
56
|
set(target, difPath, patchItem.value);
|
|
57
|
+
changed = true;
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
|
-
return
|
|
60
|
+
return changed;
|
|
52
61
|
}
|
|
53
62
|
export function revertPatchLog(patchLog, target) {
|
|
54
|
-
if (!patchLog)
|
|
55
|
-
return
|
|
63
|
+
if (!target || !(patchLog === null || patchLog === void 0 ? void 0 : patchLog.length))
|
|
64
|
+
return false;
|
|
65
|
+
let changed = false;
|
|
56
66
|
for (const patchItem of patchLog) {
|
|
57
67
|
const difPath = asLodashPath(patchItem.path);
|
|
58
68
|
if (patchItem.op === "add") {
|
|
59
|
-
unset(target, difPath);
|
|
69
|
+
changed = unset(target, difPath) || changed;
|
|
60
70
|
}
|
|
61
|
-
else {
|
|
71
|
+
else if (patchItem.op !== "test") {
|
|
62
72
|
set(target, difPath, patchItem.prev);
|
|
73
|
+
changed = true;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
return
|
|
76
|
+
return changed;
|
|
66
77
|
}
|
|
78
|
+
export function immutablePatch(target, patchSrc, patchDir) {
|
|
79
|
+
const targetCopy = deepClone(target !== null && target !== void 0 ? target : {});
|
|
80
|
+
if (patchDir === "revert") {
|
|
81
|
+
revertPatchLog(patchSrc, targetCopy);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
applyPatchLog(patchSrc, targetCopy);
|
|
85
|
+
}
|
|
86
|
+
return targetCopy;
|
|
87
|
+
}
|
|
88
|
+
;
|
|
67
89
|
function escapePathPart(path) {
|
|
68
90
|
if (typeof path === 'number')
|
|
69
91
|
return path.toString();
|
|
@@ -87,7 +109,7 @@ export function asLodashPath(pointer) {
|
|
|
87
109
|
.map((s) => unescapePathPart(s));
|
|
88
110
|
return !(parts === null || parts === void 0 ? void 0 : parts.length) ? [] : toPath(parts.join("."));
|
|
89
111
|
}
|
|
90
|
-
export function
|
|
112
|
+
export function getPointerValue(document, pointer) {
|
|
91
113
|
return pointer === "" ? document
|
|
92
114
|
: get(document, asLodashPath(pointer));
|
|
93
115
|
}
|