@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.
Files changed (61) hide show
  1. package/.jsii +303 -29
  2. package/lib/cloudfront-distribution-helper.d.ts +29 -0
  3. package/lib/cloudfront-distribution-helper.js +81 -1
  4. package/node_modules/deep-diff/.circleci/config.yml +76 -0
  5. package/node_modules/deep-diff/.eslintrc +72 -0
  6. package/node_modules/deep-diff/.vscode/launch.json +30 -0
  7. package/node_modules/deep-diff/.vscode/tasks.json +12 -0
  8. package/node_modules/deep-diff/ChangeLog.md +63 -0
  9. package/node_modules/deep-diff/LICENSE +7 -0
  10. package/node_modules/deep-diff/Readme.md +239 -0
  11. package/node_modules/deep-diff/dist/deep-diff.min.js +1 -0
  12. package/node_modules/deep-diff/dist/deep-diff.min.js.map +1 -0
  13. package/node_modules/deep-diff/examples/apply-diff-from-any.js +39 -0
  14. package/node_modules/deep-diff/examples/array-change.js +45 -0
  15. package/node_modules/deep-diff/examples/capture_change_apply_elsewhere.js +53 -0
  16. package/node_modules/deep-diff/examples/diff-ignoring-fun.js +88 -0
  17. package/node_modules/deep-diff/examples/diff-scenarios.js +49 -0
  18. package/node_modules/deep-diff/examples/example1.js +41 -0
  19. package/node_modules/deep-diff/examples/issue-111.js +6 -0
  20. package/node_modules/deep-diff/examples/issue-113-1.js +14 -0
  21. package/node_modules/deep-diff/examples/issue-113-2.js +11 -0
  22. package/node_modules/deep-diff/examples/issue-115.js +17 -0
  23. package/node_modules/deep-diff/examples/issue-124.js +8 -0
  24. package/node_modules/deep-diff/examples/issue-125.js +19 -0
  25. package/node_modules/deep-diff/examples/issue-126.js +33 -0
  26. package/node_modules/deep-diff/examples/issue-35.js +11 -0
  27. package/node_modules/deep-diff/examples/issue-47.js +17 -0
  28. package/node_modules/deep-diff/examples/issue-48.js +48 -0
  29. package/node_modules/deep-diff/examples/issue-62.js +14 -0
  30. package/node_modules/deep-diff/examples/issue-70.js +6 -0
  31. package/node_modules/deep-diff/examples/issue-71.js +15 -0
  32. package/node_modules/deep-diff/examples/issue-72.js +21 -0
  33. package/node_modules/deep-diff/examples/issue-74.js +9 -0
  34. package/node_modules/deep-diff/examples/issue-78.js +24 -0
  35. package/node_modules/deep-diff/examples/issue-83.js +11 -0
  36. package/node_modules/deep-diff/examples/issue-88.js +26 -0
  37. package/node_modules/deep-diff/examples/performance.js +64 -0
  38. package/node_modules/deep-diff/examples/practice-data.json +2501 -0
  39. package/node_modules/deep-diff/index.js +526 -0
  40. package/node_modules/deep-diff/package.json +74 -0
  41. package/node_modules/deep-diff/test/.eslintrc +10 -0
  42. package/node_modules/deep-diff/test/tests.html +34 -0
  43. package/node_modules/deep-diff/test/tests.js +759 -0
  44. package/node_modules/deepmerge/.editorconfig +7 -0
  45. package/node_modules/deepmerge/.eslintcache +1 -0
  46. package/node_modules/deepmerge/changelog.md +167 -0
  47. package/node_modules/deepmerge/dist/cjs.js +133 -0
  48. package/node_modules/deepmerge/dist/umd.js +139 -0
  49. package/node_modules/deepmerge/index.d.ts +20 -0
  50. package/node_modules/deepmerge/index.js +106 -0
  51. package/node_modules/deepmerge/license.txt +21 -0
  52. package/node_modules/deepmerge/package.json +42 -0
  53. package/node_modules/deepmerge/readme.md +264 -0
  54. package/node_modules/deepmerge/rollup.config.js +22 -0
  55. package/node_modules/npmlog/LICENSE.md +20 -0
  56. package/node_modules/npmlog/README.md +216 -0
  57. package/node_modules/npmlog/lib/log.js +400 -0
  58. package/node_modules/npmlog/package.json +52 -0
  59. package/nohoist.sh +11 -0
  60. package/package.json +3 -2
  61. package/test/cloudfront-distribution-s3-helper.test.js +455 -1
@@ -0,0 +1,239 @@
1
+ # deep-diff
2
+
3
+ [![CircleCI](https://circleci.com/gh/flitbit/diff.svg?style=svg)](https://circleci.com/gh/flitbit/diff)
4
+
5
+ [![NPM](https://nodei.co/npm/deep-diff.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-diff/)
6
+
7
+ **deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install deep-diff
13
+ ```
14
+
15
+ Possible v1.0.0 incompatabilities:
16
+
17
+ * elements in arrays are now processed in reverse order, which fixes a few nagging bugs but may break some users
18
+ * If your code relied on the order in which the differences were reported then your code will break. If you consider an object graph to be a big tree, then `deep-diff` does a [pre-order traversal of the object graph](https://en.wikipedia.org/wiki/Tree_traversal), however, when it encounters an array, the array is processed from the end towards the front, with each element recursively processed in-order during further descent.
19
+
20
+ ## Features
21
+
22
+ * Get the structural differences between two objects.
23
+ * Observe the structural differences between two objects.
24
+ * When structural differences represent change, apply change from one object to another.
25
+ * When structural differences represent change, selectively apply change from one object to another.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install deep-diff
31
+ ```
32
+
33
+ ### Importing
34
+
35
+ #### nodejs
36
+
37
+ ```javascript
38
+ var diff = require('deep-diff')
39
+ // or:
40
+ // const diff = require('deep-diff');
41
+ // const { diff } = require('deep-diff');
42
+ // or:
43
+ // const DeepDiff = require('deep-diff');
44
+ // const { DeepDiff } = require('deep-diff');
45
+ // es6+:
46
+ // import diff from 'deep-diff';
47
+ // import { diff } from 'deep-diff';
48
+ // es6+:
49
+ // import DeepDiff from 'deep-diff';
50
+ // import { DeepDiff } from 'deep-diff';
51
+ ```
52
+
53
+ #### browser
54
+
55
+ ```html
56
+ <script src="https://cdn.jsdelivr.net/npm/deep-diff@1/dist/deep-diff.min.js"></script>
57
+ ```
58
+
59
+ > In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namespace you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`.
60
+
61
+ ## Simple Examples
62
+
63
+ In order to describe differences, change revolves around an `origin` object. For consistency, the `origin` object is always the operand on the `left-hand-side` of operations. The `comparand`, which may contain changes, is always on the `right-hand-side` of operations.
64
+
65
+ ``` javascript
66
+ var diff = require('deep-diff').diff;
67
+
68
+ var lhs = {
69
+ name: 'my object',
70
+ description: 'it\'s an object!',
71
+ details: {
72
+ it: 'has',
73
+ an: 'array',
74
+ with: ['a', 'few', 'elements']
75
+ }
76
+ };
77
+
78
+ var rhs = {
79
+ name: 'updated object',
80
+ description: 'it\'s an object!',
81
+ details: {
82
+ it: 'has',
83
+ an: 'array',
84
+ with: ['a', 'few', 'more', 'elements', { than: 'before' }]
85
+ }
86
+ };
87
+
88
+ var differences = diff(lhs, rhs);
89
+ ```
90
+
91
+ *v 0.2.0 and above* The code snippet above would result in the following structure describing the differences:
92
+
93
+ ``` javascript
94
+ [ { kind: 'E',
95
+ path: [ 'name' ],
96
+ lhs: 'my object',
97
+ rhs: 'updated object' },
98
+ { kind: 'E',
99
+ path: [ 'details', 'with', 2 ],
100
+ lhs: 'elements',
101
+ rhs: 'more' },
102
+ { kind: 'A',
103
+ path: [ 'details', 'with' ],
104
+ index: 3,
105
+ item: { kind: 'N', rhs: 'elements' } },
106
+ { kind: 'A',
107
+ path: [ 'details', 'with' ],
108
+ index: 4,
109
+ item: { kind: 'N', rhs: { than: 'before' } } } ]
110
+ ```
111
+
112
+ ### Differences
113
+
114
+ Differences are reported as one or more change records. Change records have the following structure:
115
+
116
+ * `kind` - indicates the kind of change; will be one of the following:
117
+ * `N` - indicates a newly added property/element
118
+ * `D` - indicates a property/element was deleted
119
+ * `E` - indicates a property/element was edited
120
+ * `A` - indicates a change occurred within an array
121
+ * `path` - the property path (from the left-hand-side root)
122
+ * `lhs` - the value on the left-hand-side of the comparison (undefined if kind === 'N')
123
+ * `rhs` - the value on the right-hand-side of the comparison (undefined if kind === 'D')
124
+ * `index` - when kind === 'A', indicates the array index where the change occurred
125
+ * `item` - when kind === 'A', contains a nested change record indicating the change that occurred at the array index
126
+
127
+ Change records are generated for all structural differences between `origin` and `comparand`. The methods only consider an object's own properties and array elements; those inherited from an object's prototype chain are not considered.
128
+
129
+ Changes to arrays are recorded simplistically. We care most about the shape of the structure; therefore we don't take the time to determine if an object moved from one slot in the array to another. Instead, we only record the structural
130
+ differences. If the structural differences are applied from the `comparand` to the `origin` then the two objects will compare as "deep equal" using most `isEqual` implementations such as found in [lodash](https://github.com/bestiejs/lodash) or [underscore](http://underscorejs.org/).
131
+
132
+ ### Changes
133
+
134
+ When two objects differ, you can observe the differences as they are calculated and selectively apply those changes to the origin object (left-hand-side).
135
+
136
+ ``` javascript
137
+ var observableDiff = require('deep-diff').observableDiff;
138
+ var applyChange = require('deep-diff').applyChange;
139
+
140
+ var lhs = {
141
+ name: 'my object',
142
+ description: 'it\'s an object!',
143
+ details: {
144
+ it: 'has',
145
+ an: 'array',
146
+ with: ['a', 'few', 'elements']
147
+ }
148
+ };
149
+
150
+ var rhs = {
151
+ name: 'updated object',
152
+ description: 'it\'s an object!',
153
+ details: {
154
+ it: 'has',
155
+ an: 'array',
156
+ with: ['a', 'few', 'more', 'elements', { than: 'before' }]
157
+ };
158
+
159
+ observableDiff(lhs, rhs, function (d) {
160
+ // Apply all changes except to the name property...
161
+ if (d.path[d.path.length - 1] !== 'name') {
162
+ applyChange(lhs, rhs, d);
163
+ }
164
+ });
165
+ ```
166
+
167
+ ## API Documentation
168
+
169
+ A standard import of `var diff = require('deep-diff')` is assumed in all of the code examples. The import results in an object having the following public properties:
170
+
171
+ * `diff(lhs, rhs, prefilter, acc)` &mdash; calculates the differences between two objects, optionally prefiltering elements for comparison, and optionally using the specified accumulator.
172
+ * `observableDiff(lhs, rhs, observer, prefilter)` &mdash; calculates the differences between two objects and reports each to an observer function, optionally, prefiltering elements for comparison.
173
+ * `applyDiff(target, source, filter)` &mdash; applies any structural differences from a source object to a target object, optionally filtering each difference.
174
+ * `applyChange(target, source, change)` &mdash; applies a single change record to a target object. NOTE: `source` is unused and may be removed.
175
+ * `revertChange(target, source, change)` reverts a single change record to a target object. NOTE: `source` is unused and may be removed.
176
+
177
+ ### `diff`
178
+
179
+ The `diff` function calculates the difference between two objects.
180
+
181
+ #### Arguments
182
+
183
+ * `lhs` - the left-hand operand; the origin object.
184
+ * `rhs` - the right-hand operand; the object being compared structurally with the origin object.
185
+ * `prefilter` - an optional function that determines whether difference analysis should continue down the object graph.
186
+ * `acc` - an optional accumulator/array (requirement is that it have a `push` function). Each difference is pushed to the specified accumulator.
187
+
188
+ Returns either an array of changes or, if there are no changes, `undefined`. This was originally chosen so the result would be pass a truthy test:
189
+
190
+ ```javascript
191
+ var changes = diff(obja, objb);
192
+ if (changes) {
193
+ // do something with the changes.
194
+ }
195
+ ```
196
+
197
+ #### Pre-filtering Object Properties
198
+
199
+ The `prefilter`'s signature should be `function(path, key)` and it should return a truthy value for any `path`-`key` combination that should be filtered. If filtered, the difference analysis does no further analysis of on the identified object-property path.
200
+
201
+ ```javascript
202
+ const diff = require('deep-diff');
203
+ const assert = require('assert');
204
+
205
+ const data = {
206
+ issue: 126,
207
+ submittedBy: 'abuzarhamza',
208
+ title: 'readme.md need some additional example prefilter',
209
+ posts: [
210
+ {
211
+ date: '2018-04-16',
212
+ text: `additional example for prefilter for deep-diff would be great.
213
+ https://stackoverflow.com/questions/38364639/pre-filter-condition-deep-diff-node-js`
214
+ }
215
+ ]
216
+ };
217
+
218
+ const clone = JSON.parse(JSON.stringify(data));
219
+ clone.title = 'README.MD needs additional example illustrating how to prefilter';
220
+ clone.disposition = 'completed';
221
+
222
+ const two = diff(data, clone);
223
+ const none = diff(data, clone,
224
+ (path, key) => path.length === 0 && ~['title', 'disposition'].indexOf(key)
225
+ );
226
+
227
+ assert.equal(two.length, 2, 'should reflect two differences');
228
+ assert.ok(typeof none === 'undefined', 'should reflect no differences');
229
+ ```
230
+
231
+ ## Contributing
232
+
233
+ When contributing, keep in mind that it is an objective of `deep-diff` to have no package dependencies. This may change in the future, but for now, no-dependencies.
234
+
235
+ Please run the unit tests before submitting your PR: `npm test`. Hopefully your PR includes additional unit tests to illustrate your change/modification!
236
+
237
+ When you run `npm test`, linting will be performed and any linting errors will fail the tests... this includes code formatting.
238
+
239
+ > Thanks to all those who have contributed so far!
@@ -0,0 +1 @@
1
+ !function(e,t){var n=function(e){var l=["N","E","A","D"];function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function n(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0})}function D(e,t,n){D.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:n,enumerable:!0})}function k(e,t){k.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0})}function j(e,t){j.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0})}function O(e,t,n){O.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:n,enumerable:!0})}function f(e,t,n){var r=e.slice((n||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,r),e}function w(e){var t=typeof e;return"object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"function"==typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function u(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return t}function x(e){var t=0,n=w(e);if("array"===n){e.forEach(function(e){t+=x(e)});var r="[type: array, hash: "+t+"]";return t+u(r)}if("object"===n){for(var a in e)if(e.hasOwnProperty(a)){var i="[ type: object, key: "+a+", value hash: "+x(e[a])+"]";t+=u(i)}return t}var l="[ type: "+n+" ; value: "+e+"]";return t+u(l)}function A(e,t,n,r,a,i,l,f){n=n||[],l=l||[];var u=(a=a||[]).slice(0);if(null!=i){if(r){if("function"==typeof r&&r(u,i))return;if("object"==typeof r){if(r.prefilter&&r.prefilter(u,i))return;if(r.normalize){var o=r.normalize(u,i,e,t);o&&(e=o[0],t=o[1])}}}u.push(i)}"regexp"===w(e)&&"regexp"===w(t)&&(e=e.toString(),t=t.toString());var h,s,p,c,d=typeof e,v=typeof t,b="undefined"!==d||l&&0<l.length&&l[l.length-1].lhs&&Object.getOwnPropertyDescriptor(l[l.length-1].lhs,i),g="undefined"!==v||l&&0<l.length&&l[l.length-1].rhs&&Object.getOwnPropertyDescriptor(l[l.length-1].rhs,i);if(!b&&g)n.push(new k(u,t));else if(!g&&b)n.push(new j(u,e));else if(w(e)!==w(t))n.push(new D(u,e,t));else if("date"===w(e)&&e-t!=0)n.push(new D(u,e,t));else if("object"===d&&null!==e&&null!==t){for(h=l.length-1;-1<h;--h)if(l[h].lhs===e){c=!0;break}if(c)e!==t&&n.push(new D(u,e,t));else{if(l.push({lhs:e,rhs:t}),Array.isArray(e)){for(f&&(e.sort(function(e,t){return x(e)-x(t)}),t.sort(function(e,t){return x(e)-x(t)})),h=t.length-1,s=e.length-1;s<h;)n.push(new O(u,h,new k(void 0,t[h--])));for(;h<s;)n.push(new O(u,s,new j(void 0,e[s--])));for(;0<=h;--h)A(e[h],t[h],n,r,u,h,l,f)}else{var y=Object.keys(e),m=Object.keys(t);for(h=0;h<y.length;++h)p=y[h],0<=(c=m.indexOf(p))?(A(e[p],t[p],n,r,u,p,l,f),m[c]=null):A(e[p],void 0,n,r,u,p,l,f);for(h=0;h<m.length;++h)(p=m[h])&&A(void 0,t[p],n,r,u,p,l,f)}l.length=l.length-1}}else e!==t&&("number"===d&&isNaN(e)&&isNaN(t)||n.push(new D(u,e,t)))}function o(e,t,n,r,a){var i=[];if(A(e,t,i,r,null,null,null,a),n)for(var l=0;l<i.length;++l)n(i[l]);return i}function r(e,t,n,r){var a=r?function(e){e&&r.push(e)}:void 0,i=o(e,t,a,n);return r||(i.length?i:void 0)}function a(e,t,n){if(void 0===n&&t&&~l.indexOf(t.kind)&&(n=t),e&&n&&n.kind){for(var r=e,a=-1,i=n.path?n.path.length-1:0;++a<i;)void 0===r[n.path[a]]&&(r[n.path[a]]=void 0!==n.path[a+1]&&"number"==typeof n.path[a+1]?[]:{}),r=r[n.path[a]];switch(n.kind){case"A":n.path&&void 0===r[n.path[a]]&&(r[n.path[a]]=[]),function e(t,n,r){if(r.path&&r.path.length){var a,i=t[n],l=r.path.length-1;for(a=0;a<l;a++)i=i[r.path[a]];switch(r.kind){case"A":e(i[r.path[a]],r.index,r.item);break;case"D":delete i[r.path[a]];break;case"E":case"N":i[r.path[a]]=r.rhs}}else switch(r.kind){case"A":e(t[n],r.index,r.item);break;case"D":t=f(t,n);break;case"E":case"N":t[n]=r.rhs}return t}(n.path?r[n.path[a]]:r,n.index,n.item);break;case"D":delete r[n.path[a]];break;case"E":case"N":r[n.path[a]]=n.rhs}}}t(D,n),t(k,n),t(j,n),t(O,n),Object.defineProperties(r,{diff:{value:r,enumerable:!0},orderIndependentDiff:{value:function(e,t,n,r){var a=r?function(e){e&&r.push(e)}:void 0,i=o(e,t,a,n,!0);return r||(i.length?i:void 0)},enumerable:!0},observableDiff:{value:o,enumerable:!0},orderIndependentObservableDiff:{value:function(e,t,n,r,a,i,l){return A(e,t,n,r,a,i,l,!0)},enumerable:!0},orderIndepHash:{value:x,enumerable:!0},applyDiff:{value:function(t,n,r){t&&n&&o(t,n,function(e){r&&!r(t,n,e)||a(t,n,e)})},enumerable:!0},applyChange:{value:a,enumerable:!0},revertChange:{value:function(e,t,n){if(e&&t&&n&&n.kind){var r,a,i=e;for(a=n.path.length-1,r=0;r<a;r++)void 0===i[n.path[r]]&&(i[n.path[r]]={}),i=i[n.path[r]];switch(n.kind){case"A":!function e(t,n,r){if(r.path&&r.path.length){var a,i=t[n],l=r.path.length-1;for(a=0;a<l;a++)i=i[r.path[a]];switch(r.kind){case"A":e(i[r.path[a]],r.index,r.item);break;case"D":case"E":i[r.path[a]]=r.lhs;break;case"N":delete i[r.path[a]]}}else switch(r.kind){case"A":e(t[n],r.index,r.item);break;case"D":case"E":t[n]=r.lhs;break;case"N":t=f(t,n)}return t}(i[n.path[r]],n.index,n.item);break;case"D":case"E":i[n.path[r]]=n.lhs;break;case"N":delete i[n.path[r]]}}},enumerable:!0},isConflict:{value:function(){return"undefined"!=typeof $conflict},enumerable:!0}}),r.DeepDiff=r,e&&(e.DeepDiff=r);return r}(e);if("function"==typeof define&&define.amd)define("DeepDiff",function(){return n});else if("object"==typeof exports||"object"==typeof navigator&&navigator.product.match(/ReactNative/i))module.exports=n;else{var r=e.DeepDiff;n.noConflict=function(){return e.DeepDiff===n&&(e.DeepDiff=r),n},e.DeepDiff=n}}(this);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"names":["root","factory","deepDiff","validKinds","inherits","ctor","superCtor","super_","prototype","Object","create","constructor","value","enumerable","writable","configurable","Diff","kind","path","defineProperty","this","length","DiffEdit","origin","call","DiffNew","DiffDeleted","DiffArray","index","item","arrayRemove","arr","from","to","rest","slice","push","apply","realTypeOf","subject","type","Math","Array","isArray","toString","test","hashThisString","string","hash","i","char","charCodeAt","getOrderIndependentHash","object","accum","forEach","arrayString","key","hasOwnProperty","keyValueString","stringToHash","lhs","rhs","changes","prefilter","stack","orderIndependent","currentPath","normalize","alt","j","k","other","ltype","rtype","ldefined","getOwnPropertyDescriptor","rdefined","sort","a","b","undefined","akeys","keys","pkeys","indexOf","isNaN","observableDiff","observer","accumulateDiff","difference","applyChange","target","source","change","it","last","applyArrayChange","u","defineProperties","diff","orderIndependentDiff","orderIndependentObservableDiff","orderIndepHash","applyDiff","filter","revertChange","revertArrayChange","isConflict","$conflict","DeepDiff","define","amd","exports","navigator","product","match","module","_deepdiff","noConflict"],"mappings":"CAAE,SAASA,EAAMC,GACf,IAAIC,EAqBE,SAASF,GACf,IAAIG,EAAa,CAAC,IAAK,IAAK,IAAK,KAGjC,SAASC,EAASC,EAAMC,GACtBD,EAAKE,OAASD,EACdD,EAAKG,UAAYC,OAAOC,OAAOJ,EAAUE,UAAW,CAClDG,YAAa,CACXC,MAAOP,EAC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O5E,KAAK+B,IAAM6C,EAAOjC,IAC5B,MACF,IAAK,WACIkC,EAAGD,EAAO5E,KAAK+B,UAK1B,OAAQ6C,EAAO7E,MACb,IAAK,IACH0F,EAAkB5E,EAAIH,GAAQkE,EAAOlE,MAAOkE,EAAOjE,MACnD,MACF,IAAK,IAGL,IAAK,IACHE,EAAIH,GAASkE,EAAOjC,IACpB,MACF,IAAK,IACH9B,EAAMD,EAAYC,EAAKH,GAI7B,OAAOG,EAkBD4E,CAAkBZ,EAAGD,EAAO5E,KAAK+B,IAAK6C,EAAOlE,MAAOkE,EAAOjE,MAC3D,MACF,IAAK,IAIL,IAAK,IAEHkE,EAAGD,EAAO5E,KAAK+B,IAAM6C,EAAOjC,IAC5B,MACF,IAAK,WAEIkC,EAAGD,EAAO5E,KAAK+B,OAiD1BpC,YAAY,GAEd+F,WAAY,CACVhG,MAAO,WACL,MAA4B,oBAAdiG,WAEhBhG,YAAY,KAKhB4E,EAAeqB,SAAWrB,EAOtBzF,IACFA,EAAK8G,SAAWrB,GAGlB,OAAOA,EA3gBQxF,CAAQD,GAEvB,GAAsB,mBAAX+G,QAAyBA,OAAOC,IAEvCD,OAAO,WAAY,WACf,OAAO7G,SAER,GAAuB,iBAAZ+G,SAA6C,iBAAdC,WAA0BA,UAAUC,QAAQC,MAAM,gBAE/FC,OAAOJ,QAAU/G,MACd,CAEH,IAAIoH,EAAYtH,EAAK8G,SACrB5G,EAASqH,WAAa,WAIlB,OAHIvH,EAAK8G,WAAa5G,IAClBF,EAAK8G,SAAWQ,GAEbpH,GAEXF,EAAK8G,SAAW5G,GApBrB,CAsBCkB"}
@@ -0,0 +1,39 @@
1
+ /*jshint indent:2, laxcomma:true, laxbreak:true*/
2
+ var util = require('util')
3
+ , diff = require('..')
4
+ , data = require('./practice-data')
5
+ ;
6
+
7
+ var cycle = -1
8
+ , i
9
+ , len = data.length
10
+ , prior = {}
11
+ , comparand
12
+ , records
13
+ , ch
14
+ ;
15
+
16
+ var applyEachChange = function (ch) {
17
+ diff.applyChange(prior, comparand, ch);
18
+ };
19
+
20
+ while (++cycle < 10) {
21
+ i = -1;
22
+ while (++i < len) {
23
+
24
+ comparand = data[i];
25
+
26
+ // get the difference...
27
+ records = diff(prior, comparand);
28
+
29
+ // round-trip serialize to prune the underlying types...
30
+ var serialized = JSON.stringify(records);
31
+ var desierialized = JSON.parse(serialized);
32
+
33
+ if (desierialized) {
34
+ desierialized.forEach(applyEachChange);
35
+
36
+ prior = comparand;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,45 @@
1
+ /*jshint indent:2, laxcomma:true, laxbreak:true*/
2
+ var util = require('util');
3
+ var expect = require('expect.js');
4
+ var deep = require('..');
5
+
6
+ var lhs = {
7
+ 'id': 'Release',
8
+ 'phases': [{
9
+ 'id': 'Phase1',
10
+ 'tasks': [
11
+ { 'id': 'Task1' },
12
+ { 'id': 'Task2' }
13
+ ]
14
+ }, {
15
+ 'id': 'Phase2',
16
+ 'tasks': [
17
+ { 'id': 'Task3' }
18
+ ]
19
+ }]
20
+ };
21
+ var rhs = {
22
+ 'id': 'Release',
23
+ 'phases': [{
24
+ // E: Phase1 -> Phase2
25
+ 'id': 'Phase2',
26
+ 'tasks': [
27
+ { 'id': 'Task3' }
28
+ ]
29
+ }, {
30
+ 'id': 'Phase1',
31
+ 'tasks': [
32
+ { 'id': 'Task1' },
33
+ { 'id': 'Task2' }
34
+ ]
35
+ }]
36
+ };
37
+
38
+ var diff = deep.diff(lhs, rhs);
39
+ console.log(util.inspect(diff, false, 9)); // eslint-disable-line no-console
40
+
41
+ deep.applyDiff(lhs, rhs);
42
+ console.log(util.inspect(lhs, false, 9)); // eslint-disable-line no-console
43
+
44
+ expect(lhs).to.be.eql(rhs);
45
+
@@ -0,0 +1,53 @@
1
+ /*jshint indent:2, laxcomma:true, laxbreak:true*/
2
+ var util = require('util')
3
+ , assert = require('assert')
4
+ , diff = require('..')
5
+ , data = require('./practice-data')
6
+ ;
7
+
8
+ var i = Math.floor(Math.random() * data.length) + 1;
9
+ var j = Math.floor(Math.random() * data.length) + 1;
10
+
11
+ while (j === i) {
12
+ j = Math.floor(Math.random() * data.length) + 1;
13
+ }
14
+
15
+ var source = data[i];
16
+ var comparand = data[j];
17
+
18
+ // source and comparand are different objects
19
+ assert.notEqual(source, comparand);
20
+
21
+ // source and comparand have differences in their structure
22
+ assert.notDeepEqual(source, comparand);
23
+
24
+ // record the differences between source and comparand
25
+ var changes = diff(source, comparand);
26
+
27
+ // apply the changes to the source
28
+ changes.forEach(function (change) {
29
+ diff.applyChange(source, true, change);
30
+ });
31
+
32
+ // source and copmarand are now deep equal
33
+ assert.deepEqual(source, comparand);
34
+
35
+ // Simulate serializing to a remote copy of the object (we've already go a copy, copy the changes)...
36
+
37
+ var remote = JSON.parse(JSON.stringify(source));
38
+ var remoteChanges = JSON.parse(JSON.stringify(changes));
39
+
40
+ // source and remote are different objects
41
+ assert.notEqual(source, remote);
42
+
43
+ // changes and remote changes are different objects
44
+ assert.notEqual(changes, remoteChanges);
45
+
46
+ // remote and comparand are different objects
47
+ assert.notEqual(remote, comparand);
48
+
49
+ remoteChanges.forEach(function (change) {
50
+ diff.applyChange(remote, true, change);
51
+ });
52
+
53
+ assert.deepEqual(remote, comparand);
@@ -0,0 +1,88 @@
1
+ /*jshint indent:2, laxcomma:true, laxbreak:true*/
2
+ var util = require('util')
3
+ , deep = require('..')
4
+ ;
5
+
6
+ function duckWalk() {
7
+ util.log('right step, left-step, waddle');
8
+ }
9
+
10
+ function quadrapedWalk() {
11
+ util.log('right hind-step, right fore-step, left hind-step, left fore-step');
12
+ }
13
+
14
+ var duck = {
15
+ legs: 2,
16
+ walk: duckWalk
17
+ };
18
+
19
+ var dog = {
20
+ legs: 4,
21
+ walk: quadrapedWalk
22
+ };
23
+
24
+ var diff = deep.diff(duck, dog);
25
+
26
+ // The differences will include the legs, and walk.
27
+ util.log('Differences:\r\n' + util.inspect(diff, false, 9));
28
+
29
+
30
+ // To ignore behavioral differences (functions); use observableDiff and your own accumulator:
31
+
32
+ var observed = [];
33
+ deep.observableDiff(duck, dog, function (d) {
34
+ if (d && d.lhs && typeof d.lhs !== 'function') {
35
+ observed.push(d);
36
+ }
37
+ });
38
+
39
+ util.log('Observed without recording functions:\r\n' + util.inspect(observed, false, 9));
40
+
41
+ util.log(util.inspect(dog, false, 9) + ' walking: ');
42
+ dog.walk();
43
+
44
+ // The purpose of the observableDiff fn is to allow you to observe and apply differences
45
+ // that make sense in your scenario...
46
+
47
+ // We'll make the dog act like a duck...
48
+ deep.observableDiff(dog, duck, function (d) {
49
+ deep.applyChange(dog, duck, d);
50
+ });
51
+
52
+ util.log(util.inspect(dog, false, 9) + ' walking: ');
53
+ dog.walk();
54
+
55
+ // Now there are no differences between the duck and the dog:
56
+ if (deep.diff(duck, dog)) {
57
+ util.log("Ooops, that prior statement seems to be wrong! (but it won't be)");
58
+ }
59
+
60
+ // Now assign an "equivalent" walk function...
61
+ dog.walk = function duckWalk() {
62
+ util.log('right step, left-step, waddle');
63
+ };
64
+
65
+ if (diff = deep.diff(duck, dog)) {
66
+ // The dog's walk function is an equivalent, but different duckWalk function.
67
+ util.log('Hrmm, the dog walks differently: ' + util.inspect(diff, false, 9));
68
+ }
69
+
70
+ // Use the observableDiff fn to ingore based on behavioral equivalence...
71
+
72
+ observed = [];
73
+ deep.observableDiff(duck, dog, function (d) {
74
+ // if the change is a function, only record it if the text of the fns differ:
75
+ if (d && typeof d.lhs === 'function' && typeof d.rhs === 'function') {
76
+ var leftFnText = d.lhs.toString();
77
+ var rightFnText = d.rhs.toString();
78
+ if (leftFnText !== rightFnText) {
79
+ observed.push(d);
80
+ }
81
+ } else {
82
+ observed.push(d);
83
+ }
84
+ });
85
+
86
+ if (observed.length === 0) {
87
+ util.log('Yay!, we detected that the walk functions are equivalent');
88
+ }
@@ -0,0 +1,49 @@
1
+ var util = require('util'),
2
+ expect = require('expect.js'),
3
+ eql = require('deep-equal'),
4
+ deep = require('..')
5
+ extend = util._extend;
6
+ diff = deep.diff,
7
+ apply = deep.applyDiff;
8
+
9
+ function f0() {};
10
+ function f1() {};
11
+
12
+ var one = { it: 'be one', changed: false, with: { nested: 'data'}, f: f1};
13
+ var two = { it: 'be two', updated: true, changed: true, with: {nested: 'data', and: 'other', plus: one} };
14
+ var circ = {};
15
+ var other = { it: 'be other', numero: 34.29, changed: [ { it: 'is the same' }, 13.3, 'get some' ], with: {nested: 'reference', plus: circ} };
16
+ var circular = extend(circ, { it: 'be circ', updated: false, changed: [ { it: 'is not same' }, 13.3, 'get some!', {extra: 'stuff'}], with: { nested: 'reference', circular: other } });
17
+
18
+ util.log(util.inspect(diff(one, two), false, 99));
19
+ util.log(util.inspect(diff(two, one), false, 99));
20
+
21
+ util.log(util.inspect(diff(other, circular), false, 99));
22
+
23
+ var clone = extend({}, one);
24
+ apply(clone, two);
25
+ util.log(util.inspect(clone, false, 99));
26
+
27
+ expect(eql(clone, two)).to.be(true);
28
+ expect(eql(clone, one)).to.be(false);
29
+
30
+ clone = extend({}, circular);
31
+ apply(clone, other);
32
+ util.log(util.inspect(clone, false, 99));
33
+ expect(eql(clone, other)).to.be(true);
34
+ expect(eql(clone, circular)).to.be(false);
35
+
36
+
37
+ var array = { name: 'array two levels deep', item: { arr: ['it', { has: 'data' }]}};
38
+ var arrayChange = { name: 'array change two levels deep', item: { arr: ['it', { changes: 'data' }]}};
39
+
40
+ util.log(util.inspect(diff(array, arrayChange), false, 99));
41
+ clone = extend({}, array);
42
+ apply(clone, arrayChange);
43
+ util.log(util.inspect(clone, false, 99));
44
+ expect(eql(clone, arrayChange)).to.be(true);
45
+
46
+ var one_prop = { one: 'property' };
47
+ var d = diff(one_prop, {});
48
+ expect(d.length).to.be(1);
49
+
@@ -0,0 +1,41 @@
1
+ var util = require('util')
2
+ , deep = require('..')
3
+ ;
4
+
5
+ var lhs = {
6
+ name: 'my object',
7
+ description: 'it\'s an object!',
8
+ details: {
9
+ it: 'has',
10
+ an: 'array',
11
+ with: ['a', 'few', 'elements']
12
+ }
13
+ };
14
+
15
+ var rhs = {
16
+ name: 'updated object',
17
+ description: 'it\'s an object!',
18
+ details: {
19
+ it: 'has',
20
+ an: 'array',
21
+ with: ['a', 'few', 'more', 'elements', { than: 'before' }]
22
+ }
23
+ };
24
+
25
+ var differences = deep.diff(lhs, rhs);
26
+
27
+ // Print the differences to the console...
28
+ util.log(util.inspect(differences, false, 99));
29
+
30
+ deep.observableDiff(lhs, rhs, function (d) {
31
+ // Apply all changes except those to the 'name' property...
32
+ if (d.path.length !== 1 || d.path.join('.') !== 'name') {
33
+ deep.applyChange(lhs, rhs, d);
34
+ }
35
+ }, function (path, key) {
36
+ var p = (path && path.length) ? path.join('/') : '<no-path>'
37
+ util.log('prefilter: path = ' + p + ' key = ' + key);
38
+ }
39
+ );
40
+
41
+ console.log(util.inspect(lhs, false, 99));
@@ -0,0 +1,6 @@
1
+ var diff = require('../');
2
+
3
+
4
+ var differences = diff(undefined, undefined);
5
+ // eslint-disable-next-line no-console
6
+ console.log(differences);
@@ -0,0 +1,14 @@
1
+ const { log, inspect } = require('util');
2
+ const assert = require('assert');
3
+ const diff = require('../');
4
+
5
+ const o1 = {};
6
+ const o2 = {};
7
+ o1.foo = o1;
8
+ o2.foo = o2;
9
+
10
+ assert.notEqual(o1, o2, 'not same object');
11
+ assert.notEqual(o1.foo, o2.foo, 'not same object');
12
+
13
+ const differences = diff(o1, o2);
14
+ log(inspect(differences, false, 9));
@@ -0,0 +1,11 @@
1
+ const { log, inspect } = require('util');
2
+ const diff = require('../');
3
+
4
+ var o1 = {};
5
+ var o2 = {};
6
+ o1.foo = o1;
7
+ o2.foo = {foo: o2};
8
+ const differences = diff(o1, o2);
9
+
10
+ log(inspect(differences, false, 9));
11
+
@@ -0,0 +1,17 @@
1
+ var diff = require('../');
2
+ var expect = require('expect.js');
3
+
4
+ var thing1 = 'this';
5
+ var thing2 = 'that';
6
+ var thing3 = 'other';
7
+ var thing4 = 'another';
8
+
9
+ var oldArray = [thing1, thing2, thing3, thing4];
10
+ var newArray = [thing1, thing2];
11
+
12
+ diff.observableDiff(oldArray, newArray,
13
+ function (d) {
14
+ diff.applyChange(oldArray, d);
15
+ });
16
+
17
+ expect(oldArray).to.eql(newArray);
@@ -0,0 +1,8 @@
1
+ var diff = require('../');
2
+
3
+ var left = { key: [ {A: 0, B: 1}, {A: 2, B: 3} ] };
4
+ var right = { key: [ {A: 9, B: 1}, {A: 2, B: 3} ] };
5
+
6
+ var differences = diff(left, right);
7
+ // eslint-disable-next-line no-console
8
+ console.log(differences);