@aws-solutions-constructs/core 2.78.0 → 2.79.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/.jsii +303 -29
- package/lib/cloudfront-distribution-helper.d.ts +29 -0
- package/lib/cloudfront-distribution-helper.js +81 -1
- package/node_modules/deep-diff/.circleci/config.yml +76 -0
- package/node_modules/deep-diff/.eslintrc +72 -0
- package/node_modules/deep-diff/.vscode/launch.json +30 -0
- package/node_modules/deep-diff/.vscode/tasks.json +12 -0
- package/node_modules/deep-diff/ChangeLog.md +63 -0
- package/node_modules/deep-diff/LICENSE +7 -0
- package/node_modules/deep-diff/Readme.md +239 -0
- package/node_modules/deep-diff/dist/deep-diff.min.js +1 -0
- package/node_modules/deep-diff/dist/deep-diff.min.js.map +1 -0
- package/node_modules/deep-diff/examples/apply-diff-from-any.js +39 -0
- package/node_modules/deep-diff/examples/array-change.js +45 -0
- package/node_modules/deep-diff/examples/capture_change_apply_elsewhere.js +53 -0
- package/node_modules/deep-diff/examples/diff-ignoring-fun.js +88 -0
- package/node_modules/deep-diff/examples/diff-scenarios.js +49 -0
- package/node_modules/deep-diff/examples/example1.js +41 -0
- package/node_modules/deep-diff/examples/issue-111.js +6 -0
- package/node_modules/deep-diff/examples/issue-113-1.js +14 -0
- package/node_modules/deep-diff/examples/issue-113-2.js +11 -0
- package/node_modules/deep-diff/examples/issue-115.js +17 -0
- package/node_modules/deep-diff/examples/issue-124.js +8 -0
- package/node_modules/deep-diff/examples/issue-125.js +19 -0
- package/node_modules/deep-diff/examples/issue-126.js +33 -0
- package/node_modules/deep-diff/examples/issue-35.js +11 -0
- package/node_modules/deep-diff/examples/issue-47.js +17 -0
- package/node_modules/deep-diff/examples/issue-48.js +48 -0
- package/node_modules/deep-diff/examples/issue-62.js +14 -0
- package/node_modules/deep-diff/examples/issue-70.js +6 -0
- package/node_modules/deep-diff/examples/issue-71.js +15 -0
- package/node_modules/deep-diff/examples/issue-72.js +21 -0
- package/node_modules/deep-diff/examples/issue-74.js +9 -0
- package/node_modules/deep-diff/examples/issue-78.js +24 -0
- package/node_modules/deep-diff/examples/issue-83.js +11 -0
- package/node_modules/deep-diff/examples/issue-88.js +26 -0
- package/node_modules/deep-diff/examples/performance.js +64 -0
- package/node_modules/deep-diff/examples/practice-data.json +2501 -0
- package/node_modules/deep-diff/index.js +526 -0
- package/node_modules/deep-diff/package.json +74 -0
- package/node_modules/deep-diff/test/.eslintrc +10 -0
- package/node_modules/deep-diff/test/tests.html +34 -0
- package/node_modules/deep-diff/test/tests.js +759 -0
- package/node_modules/deepmerge/.editorconfig +7 -0
- package/node_modules/deepmerge/.eslintcache +1 -0
- package/node_modules/deepmerge/changelog.md +167 -0
- package/node_modules/deepmerge/dist/cjs.js +133 -0
- package/node_modules/deepmerge/dist/umd.js +139 -0
- package/node_modules/deepmerge/index.d.ts +20 -0
- package/node_modules/deepmerge/index.js +106 -0
- package/node_modules/deepmerge/license.txt +21 -0
- package/node_modules/deepmerge/package.json +42 -0
- package/node_modules/deepmerge/readme.md +264 -0
- package/node_modules/deepmerge/rollup.config.js +22 -0
- package/node_modules/npmlog/LICENSE.md +20 -0
- package/node_modules/npmlog/README.md +216 -0
- package/node_modules/npmlog/lib/log.js +400 -0
- package/node_modules/npmlog/package.json +52 -0
- package/nohoist.sh +11 -0
- package/package.json +3 -2
- package/test/cloudfront-distribution-s3-helper.test.js +455 -1
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
;(function(root, factory) { // eslint-disable-line no-extra-semi
|
|
2
|
+
var deepDiff = factory(root);
|
|
3
|
+
// eslint-disable-next-line no-undef
|
|
4
|
+
if (typeof define === 'function' && define.amd) {
|
|
5
|
+
// AMD
|
|
6
|
+
define('DeepDiff', function() { // eslint-disable-line no-undef
|
|
7
|
+
return deepDiff;
|
|
8
|
+
});
|
|
9
|
+
} else if (typeof exports === 'object' || typeof navigator === 'object' && navigator.product.match(/ReactNative/i)) {
|
|
10
|
+
// Node.js or ReactNative
|
|
11
|
+
module.exports = deepDiff;
|
|
12
|
+
} else {
|
|
13
|
+
// Browser globals
|
|
14
|
+
var _deepdiff = root.DeepDiff;
|
|
15
|
+
deepDiff.noConflict = function() {
|
|
16
|
+
if (root.DeepDiff === deepDiff) {
|
|
17
|
+
root.DeepDiff = _deepdiff;
|
|
18
|
+
}
|
|
19
|
+
return deepDiff;
|
|
20
|
+
};
|
|
21
|
+
root.DeepDiff = deepDiff;
|
|
22
|
+
}
|
|
23
|
+
}(this, function(root) {
|
|
24
|
+
var validKinds = ['N', 'E', 'A', 'D'];
|
|
25
|
+
|
|
26
|
+
// nodejs compatible on server side and in the browser.
|
|
27
|
+
function inherits(ctor, superCtor) {
|
|
28
|
+
ctor.super_ = superCtor;
|
|
29
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
30
|
+
constructor: {
|
|
31
|
+
value: ctor,
|
|
32
|
+
enumerable: false,
|
|
33
|
+
writable: true,
|
|
34
|
+
configurable: true
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function Diff(kind, path) {
|
|
40
|
+
Object.defineProperty(this, 'kind', {
|
|
41
|
+
value: kind,
|
|
42
|
+
enumerable: true
|
|
43
|
+
});
|
|
44
|
+
if (path && path.length) {
|
|
45
|
+
Object.defineProperty(this, 'path', {
|
|
46
|
+
value: path,
|
|
47
|
+
enumerable: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DiffEdit(path, origin, value) {
|
|
53
|
+
DiffEdit.super_.call(this, 'E', path);
|
|
54
|
+
Object.defineProperty(this, 'lhs', {
|
|
55
|
+
value: origin,
|
|
56
|
+
enumerable: true
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, 'rhs', {
|
|
59
|
+
value: value,
|
|
60
|
+
enumerable: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
inherits(DiffEdit, Diff);
|
|
64
|
+
|
|
65
|
+
function DiffNew(path, value) {
|
|
66
|
+
DiffNew.super_.call(this, 'N', path);
|
|
67
|
+
Object.defineProperty(this, 'rhs', {
|
|
68
|
+
value: value,
|
|
69
|
+
enumerable: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
inherits(DiffNew, Diff);
|
|
73
|
+
|
|
74
|
+
function DiffDeleted(path, value) {
|
|
75
|
+
DiffDeleted.super_.call(this, 'D', path);
|
|
76
|
+
Object.defineProperty(this, 'lhs', {
|
|
77
|
+
value: value,
|
|
78
|
+
enumerable: true
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
inherits(DiffDeleted, Diff);
|
|
82
|
+
|
|
83
|
+
function DiffArray(path, index, item) {
|
|
84
|
+
DiffArray.super_.call(this, 'A', path);
|
|
85
|
+
Object.defineProperty(this, 'index', {
|
|
86
|
+
value: index,
|
|
87
|
+
enumerable: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(this, 'item', {
|
|
90
|
+
value: item,
|
|
91
|
+
enumerable: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
inherits(DiffArray, Diff);
|
|
95
|
+
|
|
96
|
+
function arrayRemove(arr, from, to) {
|
|
97
|
+
var rest = arr.slice((to || from) + 1 || arr.length);
|
|
98
|
+
arr.length = from < 0 ? arr.length + from : from;
|
|
99
|
+
arr.push.apply(arr, rest);
|
|
100
|
+
return arr;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function realTypeOf(subject) {
|
|
104
|
+
var type = typeof subject;
|
|
105
|
+
if (type !== 'object') {
|
|
106
|
+
return type;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (subject === Math) {
|
|
110
|
+
return 'math';
|
|
111
|
+
} else if (subject === null) {
|
|
112
|
+
return 'null';
|
|
113
|
+
} else if (Array.isArray(subject)) {
|
|
114
|
+
return 'array';
|
|
115
|
+
} else if (Object.prototype.toString.call(subject) === '[object Date]') {
|
|
116
|
+
return 'date';
|
|
117
|
+
} else if (typeof subject.toString === 'function' && /^\/.*\//.test(subject.toString())) {
|
|
118
|
+
return 'regexp';
|
|
119
|
+
}
|
|
120
|
+
return 'object';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
124
|
+
function hashThisString(string) {
|
|
125
|
+
var hash = 0;
|
|
126
|
+
if (string.length === 0) { return hash; }
|
|
127
|
+
for (var i = 0; i < string.length; i++) {
|
|
128
|
+
var char = string.charCodeAt(i);
|
|
129
|
+
hash = ((hash << 5) - hash) + char;
|
|
130
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
131
|
+
}
|
|
132
|
+
return hash;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Gets a hash of the given object in an array order-independent fashion
|
|
136
|
+
// also object key order independent (easier since they can be alphabetized)
|
|
137
|
+
function getOrderIndependentHash(object) {
|
|
138
|
+
var accum = 0;
|
|
139
|
+
var type = realTypeOf(object);
|
|
140
|
+
|
|
141
|
+
if (type === 'array') {
|
|
142
|
+
object.forEach(function (item) {
|
|
143
|
+
// Addition is commutative so this is order indep
|
|
144
|
+
accum += getOrderIndependentHash(item);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
var arrayString = '[type: array, hash: ' + accum + ']';
|
|
148
|
+
return accum + hashThisString(arrayString);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (type === 'object') {
|
|
152
|
+
for (var key in object) {
|
|
153
|
+
if (object.hasOwnProperty(key)) {
|
|
154
|
+
var keyValueString = '[ type: object, key: ' + key + ', value hash: ' + getOrderIndependentHash(object[key]) + ']';
|
|
155
|
+
accum += hashThisString(keyValueString);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return accum;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Non object, non array...should be good?
|
|
163
|
+
var stringToHash = '[ type: ' + type + ' ; value: ' + object + ']';
|
|
164
|
+
return accum + hashThisString(stringToHash);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function deepDiff(lhs, rhs, changes, prefilter, path, key, stack, orderIndependent) {
|
|
168
|
+
changes = changes || [];
|
|
169
|
+
path = path || [];
|
|
170
|
+
stack = stack || [];
|
|
171
|
+
var currentPath = path.slice(0);
|
|
172
|
+
if (typeof key !== 'undefined' && key !== null) {
|
|
173
|
+
if (prefilter) {
|
|
174
|
+
if (typeof (prefilter) === 'function' && prefilter(currentPath, key)) {
|
|
175
|
+
return;
|
|
176
|
+
} else if (typeof (prefilter) === 'object') {
|
|
177
|
+
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (prefilter.normalize) {
|
|
181
|
+
var alt = prefilter.normalize(currentPath, key, lhs, rhs);
|
|
182
|
+
if (alt) {
|
|
183
|
+
lhs = alt[0];
|
|
184
|
+
rhs = alt[1];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
currentPath.push(key);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Use string comparison for regexes
|
|
193
|
+
if (realTypeOf(lhs) === 'regexp' && realTypeOf(rhs) === 'regexp') {
|
|
194
|
+
lhs = lhs.toString();
|
|
195
|
+
rhs = rhs.toString();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
var ltype = typeof lhs;
|
|
199
|
+
var rtype = typeof rhs;
|
|
200
|
+
var i, j, k, other;
|
|
201
|
+
|
|
202
|
+
var ldefined = ltype !== 'undefined' ||
|
|
203
|
+
(stack && (stack.length > 0) && stack[stack.length - 1].lhs &&
|
|
204
|
+
Object.getOwnPropertyDescriptor(stack[stack.length - 1].lhs, key));
|
|
205
|
+
var rdefined = rtype !== 'undefined' ||
|
|
206
|
+
(stack && (stack.length > 0) && stack[stack.length - 1].rhs &&
|
|
207
|
+
Object.getOwnPropertyDescriptor(stack[stack.length - 1].rhs, key));
|
|
208
|
+
|
|
209
|
+
if (!ldefined && rdefined) {
|
|
210
|
+
changes.push(new DiffNew(currentPath, rhs));
|
|
211
|
+
} else if (!rdefined && ldefined) {
|
|
212
|
+
changes.push(new DiffDeleted(currentPath, lhs));
|
|
213
|
+
} else if (realTypeOf(lhs) !== realTypeOf(rhs)) {
|
|
214
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
215
|
+
} else if (realTypeOf(lhs) === 'date' && (lhs - rhs) !== 0) {
|
|
216
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
217
|
+
} else if (ltype === 'object' && lhs !== null && rhs !== null) {
|
|
218
|
+
for (i = stack.length - 1; i > -1; --i) {
|
|
219
|
+
if (stack[i].lhs === lhs) {
|
|
220
|
+
other = true;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!other) {
|
|
225
|
+
stack.push({ lhs: lhs, rhs: rhs });
|
|
226
|
+
if (Array.isArray(lhs)) {
|
|
227
|
+
// If order doesn't matter, we need to sort our arrays
|
|
228
|
+
if (orderIndependent) {
|
|
229
|
+
lhs.sort(function (a, b) {
|
|
230
|
+
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
rhs.sort(function (a, b) {
|
|
234
|
+
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
i = rhs.length - 1;
|
|
238
|
+
j = lhs.length - 1;
|
|
239
|
+
while (i > j) {
|
|
240
|
+
changes.push(new DiffArray(currentPath, i, new DiffNew(undefined, rhs[i--])));
|
|
241
|
+
}
|
|
242
|
+
while (j > i) {
|
|
243
|
+
changes.push(new DiffArray(currentPath, j, new DiffDeleted(undefined, lhs[j--])));
|
|
244
|
+
}
|
|
245
|
+
for (; i >= 0; --i) {
|
|
246
|
+
deepDiff(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack, orderIndependent);
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
var akeys = Object.keys(lhs);
|
|
250
|
+
var pkeys = Object.keys(rhs);
|
|
251
|
+
for (i = 0; i < akeys.length; ++i) {
|
|
252
|
+
k = akeys[i];
|
|
253
|
+
other = pkeys.indexOf(k);
|
|
254
|
+
if (other >= 0) {
|
|
255
|
+
deepDiff(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
256
|
+
pkeys[other] = null;
|
|
257
|
+
} else {
|
|
258
|
+
deepDiff(lhs[k], undefined, changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
for (i = 0; i < pkeys.length; ++i) {
|
|
262
|
+
k = pkeys[i];
|
|
263
|
+
if (k) {
|
|
264
|
+
deepDiff(undefined, rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
stack.length = stack.length - 1;
|
|
269
|
+
} else if (lhs !== rhs) {
|
|
270
|
+
// lhs is contains a cycle at this element and it differs from rhs
|
|
271
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
272
|
+
}
|
|
273
|
+
} else if (lhs !== rhs) {
|
|
274
|
+
if (!(ltype === 'number' && isNaN(lhs) && isNaN(rhs))) {
|
|
275
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function observableDiff(lhs, rhs, observer, prefilter, orderIndependent) {
|
|
281
|
+
var changes = [];
|
|
282
|
+
deepDiff(lhs, rhs, changes, prefilter, null, null, null, orderIndependent);
|
|
283
|
+
if (observer) {
|
|
284
|
+
for (var i = 0; i < changes.length; ++i) {
|
|
285
|
+
observer(changes[i]);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return changes;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function orderIndependentDeepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
|
|
292
|
+
return deepDiff(lhs, rhs, changes, prefilter, path, key, stack, true);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function accumulateDiff(lhs, rhs, prefilter, accum) {
|
|
296
|
+
var observer = (accum) ?
|
|
297
|
+
function (difference) {
|
|
298
|
+
if (difference) {
|
|
299
|
+
accum.push(difference);
|
|
300
|
+
}
|
|
301
|
+
} : undefined;
|
|
302
|
+
var changes = observableDiff(lhs, rhs, observer, prefilter);
|
|
303
|
+
return (accum) ? accum : (changes.length) ? changes : undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function accumulateOrderIndependentDiff(lhs, rhs, prefilter, accum) {
|
|
307
|
+
var observer = (accum) ?
|
|
308
|
+
function (difference) {
|
|
309
|
+
if (difference) {
|
|
310
|
+
accum.push(difference);
|
|
311
|
+
}
|
|
312
|
+
} : undefined;
|
|
313
|
+
var changes = observableDiff(lhs, rhs, observer, prefilter, true);
|
|
314
|
+
return (accum) ? accum : (changes.length) ? changes : undefined;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function applyArrayChange(arr, index, change) {
|
|
318
|
+
if (change.path && change.path.length) {
|
|
319
|
+
var it = arr[index],
|
|
320
|
+
i, u = change.path.length - 1;
|
|
321
|
+
for (i = 0; i < u; i++) {
|
|
322
|
+
it = it[change.path[i]];
|
|
323
|
+
}
|
|
324
|
+
switch (change.kind) {
|
|
325
|
+
case 'A':
|
|
326
|
+
applyArrayChange(it[change.path[i]], change.index, change.item);
|
|
327
|
+
break;
|
|
328
|
+
case 'D':
|
|
329
|
+
delete it[change.path[i]];
|
|
330
|
+
break;
|
|
331
|
+
case 'E':
|
|
332
|
+
case 'N':
|
|
333
|
+
it[change.path[i]] = change.rhs;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
switch (change.kind) {
|
|
338
|
+
case 'A':
|
|
339
|
+
applyArrayChange(arr[index], change.index, change.item);
|
|
340
|
+
break;
|
|
341
|
+
case 'D':
|
|
342
|
+
arr = arrayRemove(arr, index);
|
|
343
|
+
break;
|
|
344
|
+
case 'E':
|
|
345
|
+
case 'N':
|
|
346
|
+
arr[index] = change.rhs;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return arr;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function applyChange(target, source, change) {
|
|
354
|
+
if (typeof change === 'undefined' && source && ~validKinds.indexOf(source.kind)) {
|
|
355
|
+
change = source;
|
|
356
|
+
}
|
|
357
|
+
if (target && change && change.kind) {
|
|
358
|
+
var it = target,
|
|
359
|
+
i = -1,
|
|
360
|
+
last = change.path ? change.path.length - 1 : 0;
|
|
361
|
+
while (++i < last) {
|
|
362
|
+
if (typeof it[change.path[i]] === 'undefined') {
|
|
363
|
+
it[change.path[i]] = (typeof change.path[i + 1] !== 'undefined' && typeof change.path[i + 1] === 'number') ? [] : {};
|
|
364
|
+
}
|
|
365
|
+
it = it[change.path[i]];
|
|
366
|
+
}
|
|
367
|
+
switch (change.kind) {
|
|
368
|
+
case 'A':
|
|
369
|
+
if (change.path && typeof it[change.path[i]] === 'undefined') {
|
|
370
|
+
it[change.path[i]] = [];
|
|
371
|
+
}
|
|
372
|
+
applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item);
|
|
373
|
+
break;
|
|
374
|
+
case 'D':
|
|
375
|
+
delete it[change.path[i]];
|
|
376
|
+
break;
|
|
377
|
+
case 'E':
|
|
378
|
+
case 'N':
|
|
379
|
+
it[change.path[i]] = change.rhs;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function revertArrayChange(arr, index, change) {
|
|
386
|
+
if (change.path && change.path.length) {
|
|
387
|
+
// the structure of the object at the index has changed...
|
|
388
|
+
var it = arr[index],
|
|
389
|
+
i, u = change.path.length - 1;
|
|
390
|
+
for (i = 0; i < u; i++) {
|
|
391
|
+
it = it[change.path[i]];
|
|
392
|
+
}
|
|
393
|
+
switch (change.kind) {
|
|
394
|
+
case 'A':
|
|
395
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
396
|
+
break;
|
|
397
|
+
case 'D':
|
|
398
|
+
it[change.path[i]] = change.lhs;
|
|
399
|
+
break;
|
|
400
|
+
case 'E':
|
|
401
|
+
it[change.path[i]] = change.lhs;
|
|
402
|
+
break;
|
|
403
|
+
case 'N':
|
|
404
|
+
delete it[change.path[i]];
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
// the array item is different...
|
|
409
|
+
switch (change.kind) {
|
|
410
|
+
case 'A':
|
|
411
|
+
revertArrayChange(arr[index], change.index, change.item);
|
|
412
|
+
break;
|
|
413
|
+
case 'D':
|
|
414
|
+
arr[index] = change.lhs;
|
|
415
|
+
break;
|
|
416
|
+
case 'E':
|
|
417
|
+
arr[index] = change.lhs;
|
|
418
|
+
break;
|
|
419
|
+
case 'N':
|
|
420
|
+
arr = arrayRemove(arr, index);
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return arr;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function revertChange(target, source, change) {
|
|
428
|
+
if (target && source && change && change.kind) {
|
|
429
|
+
var it = target,
|
|
430
|
+
i, u;
|
|
431
|
+
u = change.path.length - 1;
|
|
432
|
+
for (i = 0; i < u; i++) {
|
|
433
|
+
if (typeof it[change.path[i]] === 'undefined') {
|
|
434
|
+
it[change.path[i]] = {};
|
|
435
|
+
}
|
|
436
|
+
it = it[change.path[i]];
|
|
437
|
+
}
|
|
438
|
+
switch (change.kind) {
|
|
439
|
+
case 'A':
|
|
440
|
+
// Array was modified...
|
|
441
|
+
// it will be an array...
|
|
442
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
443
|
+
break;
|
|
444
|
+
case 'D':
|
|
445
|
+
// Item was deleted...
|
|
446
|
+
it[change.path[i]] = change.lhs;
|
|
447
|
+
break;
|
|
448
|
+
case 'E':
|
|
449
|
+
// Item was edited...
|
|
450
|
+
it[change.path[i]] = change.lhs;
|
|
451
|
+
break;
|
|
452
|
+
case 'N':
|
|
453
|
+
// Item is new...
|
|
454
|
+
delete it[change.path[i]];
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function applyDiff(target, source, filter) {
|
|
461
|
+
if (target && source) {
|
|
462
|
+
var onChange = function (change) {
|
|
463
|
+
if (!filter || filter(target, source, change)) {
|
|
464
|
+
applyChange(target, source, change);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
observableDiff(target, source, onChange);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
Object.defineProperties(accumulateDiff, {
|
|
472
|
+
|
|
473
|
+
diff: {
|
|
474
|
+
value: accumulateDiff,
|
|
475
|
+
enumerable: true
|
|
476
|
+
},
|
|
477
|
+
orderIndependentDiff: {
|
|
478
|
+
value: accumulateOrderIndependentDiff,
|
|
479
|
+
enumerable: true
|
|
480
|
+
},
|
|
481
|
+
observableDiff: {
|
|
482
|
+
value: observableDiff,
|
|
483
|
+
enumerable: true
|
|
484
|
+
},
|
|
485
|
+
orderIndependentObservableDiff: {
|
|
486
|
+
value: orderIndependentDeepDiff,
|
|
487
|
+
enumerable: true
|
|
488
|
+
},
|
|
489
|
+
orderIndepHash: {
|
|
490
|
+
value: getOrderIndependentHash,
|
|
491
|
+
enumerable: true
|
|
492
|
+
},
|
|
493
|
+
applyDiff: {
|
|
494
|
+
value: applyDiff,
|
|
495
|
+
enumerable: true
|
|
496
|
+
},
|
|
497
|
+
applyChange: {
|
|
498
|
+
value: applyChange,
|
|
499
|
+
enumerable: true
|
|
500
|
+
},
|
|
501
|
+
revertChange: {
|
|
502
|
+
value: revertChange,
|
|
503
|
+
enumerable: true
|
|
504
|
+
},
|
|
505
|
+
isConflict: {
|
|
506
|
+
value: function () {
|
|
507
|
+
return typeof $conflict !== 'undefined';
|
|
508
|
+
},
|
|
509
|
+
enumerable: true
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// hackish...
|
|
514
|
+
accumulateDiff.DeepDiff = accumulateDiff;
|
|
515
|
+
// ...but works with:
|
|
516
|
+
// import DeepDiff from 'deep-diff'
|
|
517
|
+
// import { DeepDiff } from 'deep-diff'
|
|
518
|
+
// const DeepDiff = require('deep-diff');
|
|
519
|
+
// const { DeepDiff } = require('deep-diff');
|
|
520
|
+
|
|
521
|
+
if (root) {
|
|
522
|
+
root.DeepDiff = accumulateDiff;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return accumulateDiff;
|
|
526
|
+
}));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deep-diff",
|
|
3
|
+
"description": "Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"diff",
|
|
8
|
+
"difference",
|
|
9
|
+
"compare",
|
|
10
|
+
"change-tracking"
|
|
11
|
+
],
|
|
12
|
+
"author": "Phillip Clark <phillip@flitbit.com>",
|
|
13
|
+
"contributors": [
|
|
14
|
+
"Simen Bekkhus <sbekkhus91@gmail.com>",
|
|
15
|
+
"Paul Pflugradt <paulpflugradt@googlemail.com>",
|
|
16
|
+
"wooorm <tituswormer@gmail.com>",
|
|
17
|
+
"Nicholas Calugar <njcalugar@gmail.com>",
|
|
18
|
+
"Yandell <hyandell@amazon.com>",
|
|
19
|
+
"Thiago Santos <thia.mdossantos@gmail.com>",
|
|
20
|
+
"Steve Mao <maochenyan@gmail.com>",
|
|
21
|
+
"Mats Bryntse <mats.dev@bryntum.com>",
|
|
22
|
+
"Phillip Clark <pclark@leisurelink.com>",
|
|
23
|
+
"ZauberNerd <zaubernerd@zaubernerd.de>",
|
|
24
|
+
"ravishivt <javishi@gmail.com>",
|
|
25
|
+
"Daniel Spangler <daniel.spangler@gmail.com>",
|
|
26
|
+
"Sam Beran <sberan@gmail.com>",
|
|
27
|
+
"Thomas de Barochez <thomas.barochez+github@gmail.com>",
|
|
28
|
+
"Morton Fox <github@qslw.com>",
|
|
29
|
+
"Amila Welihinda <amilajack@users.noreply.github.com>",
|
|
30
|
+
"Will Biddy <willbiddy@gmail.com>",
|
|
31
|
+
"icesoar <icesoar@hotmail.com>",
|
|
32
|
+
"Serkan Serttop <serkanserttop@yahoo.com>",
|
|
33
|
+
"orlando <operri@opentable.com>",
|
|
34
|
+
"Tom MacWright <tmcw@users.noreply.github.com>",
|
|
35
|
+
"Denning <denningj@amazon.com>",
|
|
36
|
+
"Dan Drinkard <dan.drinkard@gmail.com>",
|
|
37
|
+
"Elad Efrat <elad@iNNU.ORG>",
|
|
38
|
+
"caasi Huang <caasi.igd@gmail.com>",
|
|
39
|
+
"Tom Ashworth <tashworth@twitter.com>"
|
|
40
|
+
],
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git://github.com/flitbit/diff.git"
|
|
44
|
+
},
|
|
45
|
+
"main": "./index.js",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prerelease": "npm run clean && npm run test",
|
|
48
|
+
"release": "uglifyjs -c -m -o dist/deep-diff.min.js --source-map -r '$,require,exports,self,module,define,navigator' index.js",
|
|
49
|
+
"clean": "rimraf dist && mkdir dist",
|
|
50
|
+
"preversion": "npm run release",
|
|
51
|
+
"postversion": "git push && git push --tags",
|
|
52
|
+
"pretest": "npm run lint",
|
|
53
|
+
"test": "mocha test/**/*.js",
|
|
54
|
+
"test:watch": "nodemon --ext js,json --ignore dist/ --exec 'npm test'",
|
|
55
|
+
"preci": "npm run lint",
|
|
56
|
+
"ci": "mocha --reporter mocha-junit-reporter test/**/*.js",
|
|
57
|
+
"lint": "eslint index.js test"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"bluebird": "^3.5.1",
|
|
61
|
+
"deep-equal": "^1.0.1",
|
|
62
|
+
"eslint": "^4.19.1",
|
|
63
|
+
"eslint-plugin-mocha": "^5.0.0",
|
|
64
|
+
"expect.js": "^0.3.1",
|
|
65
|
+
"json": "^9.0.6",
|
|
66
|
+
"json-ptr": "^1.1.0",
|
|
67
|
+
"lodash": "^4.17.10",
|
|
68
|
+
"mocha": "^5.1.1",
|
|
69
|
+
"mocha-junit-reporter": "^1.17.0",
|
|
70
|
+
"nodemon": "^1.17.4",
|
|
71
|
+
"rimraf": "^2.6.2",
|
|
72
|
+
"uglify-js": "^3.3.25"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Mocha Tests</title>
|
|
6
|
+
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<!-- You should open this file directly in a browser from your file system, not from a server... -->
|
|
11
|
+
<div id="mocha"></div>
|
|
12
|
+
<script>
|
|
13
|
+
globalConflict = "This is a conflict";
|
|
14
|
+
DeepDiff = globalConflict;
|
|
15
|
+
</script>
|
|
16
|
+
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
|
|
17
|
+
<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
|
|
18
|
+
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
mocha.setup('bdd')
|
|
21
|
+
</script>
|
|
22
|
+
<!--script src="../index.js"></script-->
|
|
23
|
+
<script src="../dist/deep-diff.min.js"></script>
|
|
24
|
+
<script src="tests.js"></script>
|
|
25
|
+
<script>
|
|
26
|
+
window.onload = function () {
|
|
27
|
+
mocha.checkLeaks();
|
|
28
|
+
mocha.globals(['jQuery']);
|
|
29
|
+
mocha.run();
|
|
30
|
+
};
|
|
31
|
+
</script>
|
|
32
|
+
</body>
|
|
33
|
+
|
|
34
|
+
</html>
|