datum-merge 0.3.1-alpha
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/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/esm/data-utils.d.ts +9 -0
- package/dist/esm/data-utils.js +84 -0
- package/dist/esm/data-utils.js.map +1 -0
- package/dist/esm/diff-high.d.ts +4 -0
- package/dist/esm/diff-high.js +48 -0
- package/dist/esm/diff-high.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/merge-high.d.ts +37 -0
- package/dist/esm/merge-high.js +56 -0
- package/dist/esm/merge-high.js.map +1 -0
- package/dist/esm/merge-low.d.ts +25 -0
- package/dist/esm/merge-low.js +160 -0
- package/dist/esm/merge-low.js.map +1 -0
- package/dist/esm/type-utils.d.ts +24 -0
- package/dist/esm/type-utils.js +60 -0
- package/dist/esm/type-utils.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Rohit Kulkarni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# datum-merge
|
|
2
|
+
|
|
3
|
+
**datum-merge** is a modern typescript library that simplifies merge and diff operations for deeply nested objects.
|
|
4
|
+
|
|
5
|
+
**Source Code** : https://github.com/therohk/datum-merge
|
|
6
|
+
|
|
7
|
+
**NPM library** : https://www.npmjs.com/package/datum-merge
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Upcoming Features
|
|
14
|
+
|
|
15
|
+
1. inline entire [deep-diff](https://github.com/flitbit/diff) library which is unmaintained and contains serious bugs.
|
|
16
|
+
|
|
17
|
+
2. support merging for top level arrays or primitives.
|
|
18
|
+
|
|
19
|
+
3. project should compile in strict mode.
|
|
20
|
+
|
|
21
|
+
4. formalize support for deeply nested objects (for v1).
|
|
22
|
+
|
|
23
|
+
Code contributions are welcome via issues and pull requests.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
import { merge, MergeConfig, UpdateCode } from "datum-merge";
|
|
31
|
+
const conf: MergeConfig = {
|
|
32
|
+
"id": UpdateCode.I,
|
|
33
|
+
"field1": UpdateCode.B,
|
|
34
|
+
"arr*": UpdateCode.XM,
|
|
35
|
+
nested: UpdatedCode.N,
|
|
36
|
+
"obj1": {
|
|
37
|
+
scalar: UpdateCode.B,
|
|
38
|
+
vector: UpdateCode.XM,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const diff = merge(target, source, conf);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Merge Strategy
|
|
45
|
+
|
|
46
|
+
This string code describes how modifications to an attribute for a PUT/UPDATE operation should be handled.
|
|
47
|
+
It decides whether a change to the value of the field is allowed during a merge operation between two entities.
|
|
48
|
+
|
|
49
|
+
### Strategy Codes
|
|
50
|
+
|
|
51
|
+
The same field within a source and target object is represented by `s` and `t` respectively.
|
|
52
|
+
Whether the strategy requires data to be present for the field, is shown by { 0=no, 1=yes, X=irrelavant }.
|
|
53
|
+
The value of the source field is migrated to the target field only if the predicate passes.
|
|
54
|
+
See the implementation of this logic in [merge-low.ts](src/merge-low.ts).
|
|
55
|
+
|
|
56
|
+
| Code Value | Predicate | Meaning |
|
|
57
|
+
|----|----|----|
|
|
58
|
+
| C | n/a | always create new instance |
|
|
59
|
+
| N | `0` | reject any change, skip merge |
|
|
60
|
+
| Y | `sX & tX` | accept any change ; bypass merge |
|
|
61
|
+
| B | `s1 & tX` | insert or update, no delete |
|
|
62
|
+
| H | `s1 & t1` | update only if exists |
|
|
63
|
+
| U | `sX & t1` | update or delete only, no insert |
|
|
64
|
+
| I | `sX & t0` | insert only, no update or delete |
|
|
65
|
+
| D | `s0 & tX` | delete only, no update or insert |
|
|
66
|
+
| XR | `sX & tX` | full vector replacement |
|
|
67
|
+
| XM | `s ∪ t` | set union, vector merge |
|
|
68
|
+
| XD | `s - t` | set difference, delete given values |
|
|
69
|
+
| XI | `s ∩ t` | set intersection, delete missing values |
|
|
70
|
+
| XS | `s + t` | preserve order insert (allows dupes) |
|
|
71
|
+
| XF | `t + s` | insert from start (allows dupes) |
|
|
72
|
+
|
|
73
|
+
Applying the merge results in one of these transitions per primitive value in the target object.
|
|
74
|
+
|
|
75
|
+
| Code Value | Meaning | Transitions |
|
|
76
|
+
|----|----|----|
|
|
77
|
+
| Z | noop / ignore | `null <- null` or `non-null == non-null` |
|
|
78
|
+
| N | new / insert | `null <- non-null` |
|
|
79
|
+
| E | edit / update | `non-null <- non-null` |
|
|
80
|
+
| D | unset / delete | `non-null <- null` |
|
|
81
|
+
|
|
82
|
+
---
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function getObjectKeys(obj: any, excludeKeys?: string[], includeKeys?: string[]): string[];
|
|
2
|
+
export declare function createGlobRegex(search: string): RegExp;
|
|
3
|
+
export declare function deepEquals(lhs: any, rhs: any): boolean;
|
|
4
|
+
export declare function objToString(value: any): string;
|
|
5
|
+
export declare function deepClone(val: any): any;
|
|
6
|
+
export declare function toUniqueArray<T>(arr: T[]): T[];
|
|
7
|
+
export declare function areArraysEqual<T>(arr1: T[] | undefined, arr2: T[] | undefined): boolean;
|
|
8
|
+
export declare function flattenObject(obj: any): any;
|
|
9
|
+
export declare function unflattenObject(flatObj: any): any;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { cloneDeep } from "lodash-es";
|
|
2
|
+
import equal from 'fast-deep-equal';
|
|
3
|
+
export function getObjectKeys(obj, excludeKeys, includeKeys) {
|
|
4
|
+
if (!obj) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
let sourceKeys = Object.keys(obj);
|
|
8
|
+
if (includeKeys && !!includeKeys.length) {
|
|
9
|
+
includeKeys.filter((k) => !sourceKeys.includes(k))
|
|
10
|
+
.forEach((k) => sourceKeys.push(k));
|
|
11
|
+
}
|
|
12
|
+
if (excludeKeys && !!excludeKeys.length) {
|
|
13
|
+
sourceKeys = sourceKeys.filter((k) => !excludeKeys.includes(k));
|
|
14
|
+
}
|
|
15
|
+
return sourceKeys;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
export function createGlobRegex(search) {
|
|
19
|
+
let pattern = search.replace(/\*/g, ".+");
|
|
20
|
+
return new RegExp(`^${pattern}$`);
|
|
21
|
+
}
|
|
22
|
+
export function deepEquals(lhs, rhs) {
|
|
23
|
+
return equal(lhs, rhs);
|
|
24
|
+
}
|
|
25
|
+
export function objToString(value) {
|
|
26
|
+
return JSON.stringify(value, null, 1);
|
|
27
|
+
}
|
|
28
|
+
export function deepClone(val) {
|
|
29
|
+
return cloneDeep(val);
|
|
30
|
+
}
|
|
31
|
+
export function toUniqueArray(arr) {
|
|
32
|
+
return [...new Set(arr)];
|
|
33
|
+
}
|
|
34
|
+
export function areArraysEqual(arr1, arr2) {
|
|
35
|
+
if (arr1 == null && arr2 == null)
|
|
36
|
+
return true;
|
|
37
|
+
if (arr1 == null || arr2 == null)
|
|
38
|
+
return false;
|
|
39
|
+
if (arr1.length !== arr2.length)
|
|
40
|
+
return false;
|
|
41
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
42
|
+
if (arr1[i] !== arr2[i]) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
export function flattenObject(obj) {
|
|
49
|
+
const flatten = {};
|
|
50
|
+
const path = [];
|
|
51
|
+
const isObject = (value) => Object(value) === value;
|
|
52
|
+
function dig(obj) {
|
|
53
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
54
|
+
path.push(key);
|
|
55
|
+
if (isObject(value)) {
|
|
56
|
+
dig(value);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
flatten[path.join('.')] = value;
|
|
60
|
+
}
|
|
61
|
+
path.pop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
dig(obj);
|
|
65
|
+
return flatten;
|
|
66
|
+
}
|
|
67
|
+
export function unflattenObject(flatObj) {
|
|
68
|
+
const unFlatten = {};
|
|
69
|
+
for (const [path, value] of Object.entries(flatObj)) {
|
|
70
|
+
const chain = path.split('.');
|
|
71
|
+
let object = unFlatten;
|
|
72
|
+
for (const [i, key] of chain.slice(0, -1).entries()) {
|
|
73
|
+
if (!object[key]) {
|
|
74
|
+
const needArray = Number.isInteger(Number(chain[+i + 1]));
|
|
75
|
+
object[key] = needArray ? [] : {};
|
|
76
|
+
}
|
|
77
|
+
object = object[key];
|
|
78
|
+
}
|
|
79
|
+
const lastkey = chain.pop();
|
|
80
|
+
object[lastkey] = value;
|
|
81
|
+
}
|
|
82
|
+
return unFlatten;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=data-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-utils.js","sourceRoot":"","sources":["../../src/data-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAEpC,MAAM,UAAU,aAAa,CACzB,GAAQ,EACR,WAAsB,EACtB,WAAsB;IAEtB,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QAEtC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aAC7C,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,eAAe,CAC3B,MAAc;IAEd,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,C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CAAC,CAAC,EAAE,CAAC;YACtC,CAAC;YACD,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAC5B,MAAM,CAAC,OAAQ,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Diff } from "deep-diff";
|
|
2
|
+
export declare function deepDiffFlat(oldFlat: any, newFlat: any, flatten?: boolean): [any, any];
|
|
3
|
+
export declare function deepDiffTyped<T>(lhsObj: T, rhsObj: T): Partial<T>;
|
|
4
|
+
export declare function deepDiffLow<T, S>(lhsObj: T, rhsObj: S, orderInd?: boolean): Diff<T, S>[] | false;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { applyChange, diff, orderIndependentDiff } from "deep-diff";
|
|
2
|
+
import { flattenObject, getObjectKeys } from "./data-utils";
|
|
3
|
+
export function deepDiffFlat(oldFlat, newFlat, flatten = false) {
|
|
4
|
+
if (flatten) {
|
|
5
|
+
oldFlat = flattenObject(oldFlat);
|
|
6
|
+
newFlat = flattenObject(newFlat);
|
|
7
|
+
}
|
|
8
|
+
const updated = Object.assign({}, oldFlat);
|
|
9
|
+
const removed = Object.assign({}, newFlat);
|
|
10
|
+
for (let key of Object.keys(newFlat)) {
|
|
11
|
+
if (newFlat[key] === oldFlat[key]) {
|
|
12
|
+
delete updated[key];
|
|
13
|
+
delete removed[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return [updated, removed];
|
|
17
|
+
}
|
|
18
|
+
export function deepDiffTyped(lhsObj, rhsObj) {
|
|
19
|
+
const differences = deepDiffLow(lhsObj, rhsObj);
|
|
20
|
+
const deltaObj = {};
|
|
21
|
+
if (!differences) {
|
|
22
|
+
return deltaObj;
|
|
23
|
+
}
|
|
24
|
+
for (const difference of differences) {
|
|
25
|
+
applyChange(deltaObj, null, difference);
|
|
26
|
+
}
|
|
27
|
+
cleanupObjArrays(deltaObj);
|
|
28
|
+
return deltaObj;
|
|
29
|
+
}
|
|
30
|
+
;
|
|
31
|
+
function cleanupObjArrays(obj) {
|
|
32
|
+
var _a;
|
|
33
|
+
for (const objKey of getObjectKeys(obj)) {
|
|
34
|
+
if ((_a = obj[objKey]) === null || _a === void 0 ? void 0 : _a.filter) {
|
|
35
|
+
obj[objKey] = obj[objKey].filter((e) => !!e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function deepDiffLow(lhsObj, rhsObj, orderInd = false) {
|
|
40
|
+
const differences = !orderInd
|
|
41
|
+
? diff(lhsObj, rhsObj)
|
|
42
|
+
: orderIndependentDiff(lhsObj, rhsObj);
|
|
43
|
+
return !(differences === null || differences === void 0 ? void 0 : differences.length)
|
|
44
|
+
? false
|
|
45
|
+
: differences;
|
|
46
|
+
}
|
|
47
|
+
;
|
|
48
|
+
//# sourceMappingURL=diff-high.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-high.js","sourceRoot":"","sources":["../../src/diff-high.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,MAAM,UAAU,YAAY,CACxB,OAAY,EACZ,OAAY,EACZ,OAAO,GAAG,KAAK;IAEf,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO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AAI,CAAC,MAAM,EAAE,MAAM,CAAC;QACtB,CAAC,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,CAAA;QACvB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,WAAW,CAAC;AACtB,CAAC;AAAA,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { deepEquals } from "./data-utils";
|
|
2
|
+
export { flattenObject, unflattenObject } from "./data-utils";
|
|
3
|
+
export { deepDiffLow } from "./diff-high";
|
|
4
|
+
export { deepDiffFlat } from "./diff-high";
|
|
5
|
+
export { deepDiffTyped } from "./diff-high";
|
|
6
|
+
export { UpdateCode } from "./merge-low";
|
|
7
|
+
export { updateCodeInfo } from "./merge-low";
|
|
8
|
+
export { MergeError } from "./merge-high";
|
|
9
|
+
export { shallowMerge, immutableMerge } from "./merge-high";
|
|
10
|
+
export { type DetailConfig, detailMerge } from "./merge-high";
|
|
11
|
+
export { diffFromMerge } from "./merge-high";
|
|
12
|
+
export { shallowMerge as merge } from "./merge-high";
|
|
13
|
+
export { deepDiffTyped as diff } from "./diff-high";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { deepEquals } from "./data-utils";
|
|
2
|
+
export { flattenObject, unflattenObject } from "./data-utils";
|
|
3
|
+
export { deepDiffLow } from "./diff-high";
|
|
4
|
+
export { deepDiffFlat } from "./diff-high";
|
|
5
|
+
export { deepDiffTyped } from "./diff-high";
|
|
6
|
+
export { UpdateCode } from "./merge-low";
|
|
7
|
+
export { updateCodeInfo } from "./merge-low";
|
|
8
|
+
export { MergeError } from "./merge-high";
|
|
9
|
+
export { shallowMerge, immutableMerge } from "./merge-high";
|
|
10
|
+
export { detailMerge } from "./merge-high";
|
|
11
|
+
export { diffFromMerge } from "./merge-high";
|
|
12
|
+
export { shallowMerge as merge } from "./merge-high";
|
|
13
|
+
export { deepDiffTyped as diff } from "./diff-high";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAqB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { UpdateCode } from "./merge-low";
|
|
2
|
+
export type MergeTypes = string[] | number[] | string | number | boolean;
|
|
3
|
+
export type MergeSafeTuple = {
|
|
4
|
+
[label: string]: MergeTypes;
|
|
5
|
+
};
|
|
6
|
+
export type MergeTuple = {
|
|
7
|
+
[label: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export type MergeCode = `${UpdateCode}`;
|
|
10
|
+
export type DetailConfig = {
|
|
11
|
+
[path: string]: UpdateCode;
|
|
12
|
+
};
|
|
13
|
+
export declare class MergeError extends Error {
|
|
14
|
+
readonly data: {
|
|
15
|
+
e: string;
|
|
16
|
+
n?: string;
|
|
17
|
+
s: any;
|
|
18
|
+
v?: string;
|
|
19
|
+
t?: any;
|
|
20
|
+
};
|
|
21
|
+
readonly code = 500;
|
|
22
|
+
constructor(data: {
|
|
23
|
+
e: string;
|
|
24
|
+
n?: string;
|
|
25
|
+
s: any;
|
|
26
|
+
v?: string;
|
|
27
|
+
t?: any;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export declare function detailMerge(target: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}, source: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}, mergeCodes: DetailConfig): boolean;
|
|
35
|
+
export declare function shallowMerge(target: any, source: any, scalarCode: UpdateCode, vectorCode?: UpdateCode, excludeKeys?: string[], includeKeys?: string[]): boolean;
|
|
36
|
+
export declare function immutableMerge(target: any, source: any, scalarCode: UpdateCode, vectorCode?: UpdateCode): any;
|
|
37
|
+
export declare function diffFromMerge(target: any, source: any, scalarCode: UpdateCode, vectorCode?: UpdateCode): any | false;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { emptyObject, isVectorArray } from "./type-utils";
|
|
2
|
+
import { deepClone, getObjectKeys } from "./data-utils";
|
|
3
|
+
import { mergeScalarField, mergeVectorField } from "./merge-low";
|
|
4
|
+
import { deepDiffTyped } from "./diff-high";
|
|
5
|
+
export class MergeError extends Error {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
var _a;
|
|
8
|
+
super(data.e);
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.code = 500;
|
|
11
|
+
this.name = (_a = data.n) !== null && _a !== void 0 ? _a : 'MergeError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function detailMerge(target, source, mergeCodes) {
|
|
15
|
+
const mergeKeys = getObjectKeys(mergeCodes);
|
|
16
|
+
let changed = false;
|
|
17
|
+
for (const label of mergeKeys) {
|
|
18
|
+
const mergeCode = mergeCodes[label];
|
|
19
|
+
if (mergeCode.toString().startsWith("X")
|
|
20
|
+
? mergeVectorField(target, source, label, mergeCode)
|
|
21
|
+
: mergeScalarField(target, source, label, mergeCode)) {
|
|
22
|
+
changed = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return changed;
|
|
26
|
+
}
|
|
27
|
+
export function shallowMerge(target, source, scalarCode, vectorCode, excludeKeys, includeKeys) {
|
|
28
|
+
const sourceKeys = getObjectKeys(source, excludeKeys, includeKeys);
|
|
29
|
+
if (!(sourceKeys === null || sourceKeys === void 0 ? void 0 : sourceKeys.length)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
let changed = false;
|
|
33
|
+
for (const label of sourceKeys) {
|
|
34
|
+
if (isVectorArray(target[label]) || isVectorArray(source[label])) {
|
|
35
|
+
if (mergeVectorField(target, source, label, vectorCode !== null && vectorCode !== void 0 ? vectorCode : scalarCode)) {
|
|
36
|
+
changed = true;
|
|
37
|
+
}
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (mergeScalarField(target, source, label, scalarCode))
|
|
41
|
+
changed = true;
|
|
42
|
+
}
|
|
43
|
+
return changed;
|
|
44
|
+
}
|
|
45
|
+
export function immutableMerge(target, source, scalarCode, vectorCode) {
|
|
46
|
+
const targetCopy = deepClone(target);
|
|
47
|
+
shallowMerge(targetCopy, source, scalarCode, vectorCode);
|
|
48
|
+
return targetCopy;
|
|
49
|
+
}
|
|
50
|
+
;
|
|
51
|
+
export function diffFromMerge(target, source, scalarCode, vectorCode) {
|
|
52
|
+
const targetCopy = immutableMerge(target, source, scalarCode, vectorCode);
|
|
53
|
+
const delta = deepDiffTyped(target, targetCopy);
|
|
54
|
+
return emptyObject(delta) ? false : delta;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=merge-high.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-high.js","sourceRoot":"","sources":["../../src/merge-high.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW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,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum UpdateCode {
|
|
2
|
+
T = "T",
|
|
3
|
+
C = "C",
|
|
4
|
+
N = "N",
|
|
5
|
+
Y = "Y",
|
|
6
|
+
B = "B",
|
|
7
|
+
U = "U",
|
|
8
|
+
H = "H",
|
|
9
|
+
I = "I",
|
|
10
|
+
D = "D",
|
|
11
|
+
XR = "XR",
|
|
12
|
+
XM = "XM",
|
|
13
|
+
XD = "XD",
|
|
14
|
+
XI = "XI",
|
|
15
|
+
XS = "XS",
|
|
16
|
+
XF = "XF"
|
|
17
|
+
}
|
|
18
|
+
export declare function updateCodeInfo(mergeCode: UpdateCode): {
|
|
19
|
+
insert: boolean;
|
|
20
|
+
update: boolean;
|
|
21
|
+
unset: boolean;
|
|
22
|
+
enable: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function mergeScalarField(target: any, source: any, label: string, mergeCode: UpdateCode): boolean;
|
|
25
|
+
export declare function mergeVectorField(target: any, source: any, label: string, mergeCode: UpdateCode): boolean;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { differenceWith, intersectionWith, unionWith, isEqual } from "lodash-es";
|
|
2
|
+
import { isArrayOfAny, isNullish } from "./type-utils";
|
|
3
|
+
import { areArraysEqual, deepClone } from "./data-utils";
|
|
4
|
+
export var UpdateCode;
|
|
5
|
+
(function (UpdateCode) {
|
|
6
|
+
UpdateCode["T"] = "T";
|
|
7
|
+
UpdateCode["C"] = "C";
|
|
8
|
+
UpdateCode["N"] = "N";
|
|
9
|
+
UpdateCode["Y"] = "Y";
|
|
10
|
+
UpdateCode["B"] = "B";
|
|
11
|
+
UpdateCode["U"] = "U";
|
|
12
|
+
UpdateCode["H"] = "H";
|
|
13
|
+
UpdateCode["I"] = "I";
|
|
14
|
+
UpdateCode["D"] = "D";
|
|
15
|
+
UpdateCode["XR"] = "XR";
|
|
16
|
+
UpdateCode["XM"] = "XM";
|
|
17
|
+
UpdateCode["XD"] = "XD";
|
|
18
|
+
UpdateCode["XI"] = "XI";
|
|
19
|
+
UpdateCode["XS"] = "XS";
|
|
20
|
+
UpdateCode["XF"] = "XF";
|
|
21
|
+
})(UpdateCode || (UpdateCode = {}));
|
|
22
|
+
export function updateCodeInfo(mergeCode) {
|
|
23
|
+
const allowUnset = [
|
|
24
|
+
UpdateCode.Y, UpdateCode.D, UpdateCode.U,
|
|
25
|
+
UpdateCode.XR, UpdateCode.XD, UpdateCode.XI
|
|
26
|
+
]
|
|
27
|
+
.includes(mergeCode);
|
|
28
|
+
const allowInsert = [
|
|
29
|
+
UpdateCode.Y, UpdateCode.I, UpdateCode.B,
|
|
30
|
+
UpdateCode.XR, UpdateCode.XM, UpdateCode.XS, UpdateCode.XF
|
|
31
|
+
]
|
|
32
|
+
.includes(mergeCode);
|
|
33
|
+
const allowUpdate = [
|
|
34
|
+
UpdateCode.Y, UpdateCode.H, UpdateCode.U, UpdateCode.B
|
|
35
|
+
]
|
|
36
|
+
.includes(mergeCode)
|
|
37
|
+
|| mergeCode.startsWith("X");
|
|
38
|
+
return {
|
|
39
|
+
insert: allowInsert,
|
|
40
|
+
update: allowUpdate,
|
|
41
|
+
unset: allowUnset,
|
|
42
|
+
enable: allowInsert || allowUpdate || allowUnset,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function mergeScalarField(target, source, label, mergeCode) {
|
|
46
|
+
const sourceHas = !isNullish(source[label]);
|
|
47
|
+
const targetHas = target.hasOwnProperty(label);
|
|
48
|
+
if (!targetHas && !sourceHas) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (targetHas && sourceHas) {
|
|
52
|
+
if (typeof target[label] !== typeof source[label]) {
|
|
53
|
+
throw new TypeError("field type mismatch for " + label);
|
|
54
|
+
}
|
|
55
|
+
if (target[label] === source[label]) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let migrateVal = false;
|
|
60
|
+
switch (mergeCode) {
|
|
61
|
+
case UpdateCode.N:
|
|
62
|
+
return false;
|
|
63
|
+
case UpdateCode.Y:
|
|
64
|
+
target[label] = source[label];
|
|
65
|
+
return true;
|
|
66
|
+
case UpdateCode.B:
|
|
67
|
+
if (sourceHas)
|
|
68
|
+
migrateVal = true;
|
|
69
|
+
break;
|
|
70
|
+
case UpdateCode.U:
|
|
71
|
+
if (targetHas)
|
|
72
|
+
migrateVal = true;
|
|
73
|
+
break;
|
|
74
|
+
case UpdateCode.I:
|
|
75
|
+
if (!targetHas)
|
|
76
|
+
migrateVal = true;
|
|
77
|
+
break;
|
|
78
|
+
case UpdateCode.H:
|
|
79
|
+
if (targetHas && sourceHas)
|
|
80
|
+
migrateVal = true;
|
|
81
|
+
break;
|
|
82
|
+
case UpdateCode.D:
|
|
83
|
+
if (targetHas && !sourceHas)
|
|
84
|
+
migrateVal = true;
|
|
85
|
+
break;
|
|
86
|
+
case UpdateCode.XR:
|
|
87
|
+
case UpdateCode.XS:
|
|
88
|
+
case UpdateCode.XF:
|
|
89
|
+
case UpdateCode.XM:
|
|
90
|
+
case UpdateCode.XD:
|
|
91
|
+
case UpdateCode.XI:
|
|
92
|
+
return mergeVectorField(target, source, label, mergeCode);
|
|
93
|
+
}
|
|
94
|
+
if (migrateVal) {
|
|
95
|
+
if (sourceHas) {
|
|
96
|
+
target[label] = deepClone(source[label]);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
delete target[label];
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
export function mergeVectorField(target, source, label, mergeCode) {
|
|
107
|
+
let sourceVals = source[label];
|
|
108
|
+
if (isNullish(sourceVals)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
let sourceVec = isArrayOfAny(sourceVals);
|
|
112
|
+
const targetHas = target.hasOwnProperty(label);
|
|
113
|
+
const targetVec = isArrayOfAny(target[label]);
|
|
114
|
+
if (targetHas && !targetVec) {
|
|
115
|
+
throw new TypeError("type change to vector for " + label);
|
|
116
|
+
}
|
|
117
|
+
if (!sourceVec) {
|
|
118
|
+
sourceVals = [sourceVals];
|
|
119
|
+
sourceVec = true;
|
|
120
|
+
}
|
|
121
|
+
let targetVals;
|
|
122
|
+
switch (mergeCode) {
|
|
123
|
+
case UpdateCode.N:
|
|
124
|
+
return false;
|
|
125
|
+
case UpdateCode.Y:
|
|
126
|
+
case UpdateCode.XR:
|
|
127
|
+
target[label] = deepClone(sourceVals);
|
|
128
|
+
return true;
|
|
129
|
+
case UpdateCode.XS:
|
|
130
|
+
if (!targetHas)
|
|
131
|
+
target[label] = [];
|
|
132
|
+
target[label].push(...sourceVals);
|
|
133
|
+
return true;
|
|
134
|
+
case UpdateCode.XF:
|
|
135
|
+
if (!targetHas)
|
|
136
|
+
target[label] = [];
|
|
137
|
+
target[label].unshift(...sourceVals);
|
|
138
|
+
return true;
|
|
139
|
+
case UpdateCode.B:
|
|
140
|
+
case UpdateCode.XM:
|
|
141
|
+
targetVals = unionWith(target[label], sourceVals, isEqual);
|
|
142
|
+
break;
|
|
143
|
+
case UpdateCode.XD:
|
|
144
|
+
targetVals = differenceWith(target[label], sourceVals, isEqual);
|
|
145
|
+
break;
|
|
146
|
+
case UpdateCode.XI:
|
|
147
|
+
targetVals = intersectionWith(target[label], sourceVals, isEqual);
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
if (!(targetVals === null || targetVals === void 0 ? void 0 : targetVals.length)) {
|
|
153
|
+
delete target[label];
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
const changed = !areArraysEqual(targetVals, target[label]);
|
|
157
|
+
target[label] = targetVals;
|
|
158
|
+
return changed;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=merge-low.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-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EV,KAAK,UAAU,CAAC,EAAE;YACd,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM;QACV,KAAK,UAAU,CAAC,EAAE;YACd,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAClE,MAAM;QACV;YACI,OAAO,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAA,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAG3D,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;IAE3B,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type PrimitiveType = "string" | "number" | "boolean";
|
|
2
|
+
export type Primitive = string | number | boolean;
|
|
3
|
+
export type PrimitiveArray = string[] | number[] | boolean[];
|
|
4
|
+
export type VectorArray = string[] | number[];
|
|
5
|
+
export type ObjectKeys<T> = keyof T;
|
|
6
|
+
export type ObjectVals<T> = T[keyof T];
|
|
7
|
+
export type Prettify<T> = {
|
|
8
|
+
[K in keyof T]: T[K];
|
|
9
|
+
} & {};
|
|
10
|
+
export declare function isString(value: any): value is string;
|
|
11
|
+
export declare function isNumber(value: any): value is number;
|
|
12
|
+
export declare function isBoolean(value: any): value is boolean;
|
|
13
|
+
export declare function isPrimitive(value: any): value is Primitive;
|
|
14
|
+
export declare function isNullish(value: any): boolean;
|
|
15
|
+
export declare function emptyString(str: string): boolean;
|
|
16
|
+
export declare function integerString(str: string): boolean;
|
|
17
|
+
export declare function isRegExp(value: any): value is RegExp;
|
|
18
|
+
export declare function isObject(value: any): boolean;
|
|
19
|
+
export declare function emptyObject(obj: object): boolean;
|
|
20
|
+
export declare function isArrayOfAny(value: any): value is any[];
|
|
21
|
+
export declare function emptyArray(arr: any): boolean;
|
|
22
|
+
export declare function isArrayOf<T>(arr: any, typeCheck: (item: any) => item is T): arr is T[];
|
|
23
|
+
export declare function isArrayOfSame(arr: any): string | false;
|
|
24
|
+
export declare function isVectorArray(arr: any): arr is VectorArray;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function isString(value) {
|
|
2
|
+
return typeof value === 'string';
|
|
3
|
+
}
|
|
4
|
+
export function isNumber(value) {
|
|
5
|
+
return typeof value === 'number';
|
|
6
|
+
}
|
|
7
|
+
export function isBoolean(value) {
|
|
8
|
+
return typeof value === 'boolean';
|
|
9
|
+
}
|
|
10
|
+
export function isPrimitive(value) {
|
|
11
|
+
return ['string', 'number', 'boolean'].includes(typeof value);
|
|
12
|
+
}
|
|
13
|
+
export function isNullish(value) {
|
|
14
|
+
return value === undefined || value === null;
|
|
15
|
+
}
|
|
16
|
+
export function emptyString(str) {
|
|
17
|
+
return (str == null)
|
|
18
|
+
|| (str === '')
|
|
19
|
+
|| (/^\s*$/.test(str));
|
|
20
|
+
}
|
|
21
|
+
export function integerString(str) {
|
|
22
|
+
return ((str != null)
|
|
23
|
+
&& (str !== '')
|
|
24
|
+
&& Number.isSafeInteger(Number(str.toString())));
|
|
25
|
+
}
|
|
26
|
+
export function isRegExp(value) {
|
|
27
|
+
return value instanceof RegExp;
|
|
28
|
+
}
|
|
29
|
+
export function isObject(value) {
|
|
30
|
+
return typeof value === 'object'
|
|
31
|
+
&& !Array.isArray(value)
|
|
32
|
+
&& value !== null;
|
|
33
|
+
}
|
|
34
|
+
export function emptyObject(obj) {
|
|
35
|
+
return (obj === undefined)
|
|
36
|
+
|| (obj === null)
|
|
37
|
+
|| (!Object.keys(obj).length);
|
|
38
|
+
}
|
|
39
|
+
export function isArrayOfAny(value) {
|
|
40
|
+
return Array.isArray(value);
|
|
41
|
+
}
|
|
42
|
+
export function emptyArray(arr) {
|
|
43
|
+
return Array.isArray(arr) && !(arr === null || arr === void 0 ? void 0 : arr.length);
|
|
44
|
+
}
|
|
45
|
+
export function isArrayOf(arr, typeCheck) {
|
|
46
|
+
return Array.isArray(arr)
|
|
47
|
+
&& arr.length > 0
|
|
48
|
+
&& arr.every(typeCheck);
|
|
49
|
+
}
|
|
50
|
+
export function isArrayOfSame(arr) {
|
|
51
|
+
return Array.isArray(arr)
|
|
52
|
+
&& new Set(arr.map((e) => typeof e)).size === 1
|
|
53
|
+
? typeof arr[0] : false;
|
|
54
|
+
}
|
|
55
|
+
export function isVectorArray(arr) {
|
|
56
|
+
return Array.isArray(arr)
|
|
57
|
+
&& new Set(arr.map((e) => typeof e)).size === 1
|
|
58
|
+
&& ['string', 'number'].includes(typeof arr[0]);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=type-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../src/type-utils.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,QAAQ,CAAC,KAAU;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAU;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAU;IAChC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAU;IAClC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAU;IAChC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACjD,CA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C;WAClB,GAAG,CAAC,MAAM,GAAG,CAAC;WACd,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;WAClB,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;QAC/C,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;WAClB,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;WAC5C,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAExD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "datum-merge",
|
|
3
|
+
"version": "0.3.1-alpha",
|
|
4
|
+
"author": "Rohit Kulkarni <rohk@live.com>",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/therohk/datum-merge.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"description": "Simplified diff and merging for deeply nested objects.",
|
|
11
|
+
"keywords": ["merge", "diff", "compare", "patch", "update"],
|
|
12
|
+
"main": "dist/esm/index.js",
|
|
13
|
+
"types": "dist/esm/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "^20",
|
|
19
|
+
"npm": ">=10"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"lint": "npx eslint src",
|
|
23
|
+
"pretty": "prettier -c src",
|
|
24
|
+
"scantask": "findstr /s /i todo src\\*.*",
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"build:esm": "tsc",
|
|
27
|
+
"build:cjs": "tsc --module CommonJS --outDir dist/cjs",
|
|
28
|
+
"build": "run-s test build:*",
|
|
29
|
+
"compile": "tsc -noEmit -skipLibCheck",
|
|
30
|
+
"cyccheck": "dpdm --exit-code circular:1 --no-tree ./src"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^16.11.6",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
35
|
+
"@typescript-eslint/parser": "5.62.0",
|
|
36
|
+
"@types/lodash": "^4.14.169",
|
|
37
|
+
"@types/deep-diff": "^1.0.5",
|
|
38
|
+
"@types/lodash-es": "^4.17.12",
|
|
39
|
+
"@types/jest": "^29.5.2",
|
|
40
|
+
"eslint": "^8.0.1",
|
|
41
|
+
"prettier": "^3.1.0",
|
|
42
|
+
"npm-run-all2": "^6.2.0",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"ts-jest": "^29.1.0",
|
|
45
|
+
"ts-node": "^10.9.2",
|
|
46
|
+
"tslib": "2.4.0",
|
|
47
|
+
"typescript": "5.4.5",
|
|
48
|
+
"lodash": "^4.17.21"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"fast-deep-equal": "^3.1.3",
|
|
52
|
+
"lodash-es": "^4.17.21",
|
|
53
|
+
"deep-diff": "^1.0.2"
|
|
54
|
+
}
|
|
55
|
+
}
|