@aws-solutions-constructs/core 2.78.0 → 2.78.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.jsii +3 -3
  2. package/node_modules/deep-diff/.circleci/config.yml +76 -0
  3. package/node_modules/deep-diff/.eslintrc +72 -0
  4. package/node_modules/deep-diff/.vscode/launch.json +30 -0
  5. package/node_modules/deep-diff/.vscode/tasks.json +12 -0
  6. package/node_modules/deep-diff/ChangeLog.md +63 -0
  7. package/node_modules/deep-diff/LICENSE +7 -0
  8. package/node_modules/deep-diff/Readme.md +239 -0
  9. package/node_modules/deep-diff/dist/deep-diff.min.js +1 -0
  10. package/node_modules/deep-diff/dist/deep-diff.min.js.map +1 -0
  11. package/node_modules/deep-diff/examples/apply-diff-from-any.js +39 -0
  12. package/node_modules/deep-diff/examples/array-change.js +45 -0
  13. package/node_modules/deep-diff/examples/capture_change_apply_elsewhere.js +53 -0
  14. package/node_modules/deep-diff/examples/diff-ignoring-fun.js +88 -0
  15. package/node_modules/deep-diff/examples/diff-scenarios.js +49 -0
  16. package/node_modules/deep-diff/examples/example1.js +41 -0
  17. package/node_modules/deep-diff/examples/issue-111.js +6 -0
  18. package/node_modules/deep-diff/examples/issue-113-1.js +14 -0
  19. package/node_modules/deep-diff/examples/issue-113-2.js +11 -0
  20. package/node_modules/deep-diff/examples/issue-115.js +17 -0
  21. package/node_modules/deep-diff/examples/issue-124.js +8 -0
  22. package/node_modules/deep-diff/examples/issue-125.js +19 -0
  23. package/node_modules/deep-diff/examples/issue-126.js +33 -0
  24. package/node_modules/deep-diff/examples/issue-35.js +11 -0
  25. package/node_modules/deep-diff/examples/issue-47.js +17 -0
  26. package/node_modules/deep-diff/examples/issue-48.js +48 -0
  27. package/node_modules/deep-diff/examples/issue-62.js +14 -0
  28. package/node_modules/deep-diff/examples/issue-70.js +6 -0
  29. package/node_modules/deep-diff/examples/issue-71.js +15 -0
  30. package/node_modules/deep-diff/examples/issue-72.js +21 -0
  31. package/node_modules/deep-diff/examples/issue-74.js +9 -0
  32. package/node_modules/deep-diff/examples/issue-78.js +24 -0
  33. package/node_modules/deep-diff/examples/issue-83.js +11 -0
  34. package/node_modules/deep-diff/examples/issue-88.js +26 -0
  35. package/node_modules/deep-diff/examples/performance.js +64 -0
  36. package/node_modules/deep-diff/examples/practice-data.json +2501 -0
  37. package/node_modules/deep-diff/index.js +526 -0
  38. package/node_modules/deep-diff/package.json +74 -0
  39. package/node_modules/deep-diff/test/.eslintrc +10 -0
  40. package/node_modules/deep-diff/test/tests.html +34 -0
  41. package/node_modules/deep-diff/test/tests.js +759 -0
  42. package/node_modules/deepmerge/.editorconfig +7 -0
  43. package/node_modules/deepmerge/.eslintcache +1 -0
  44. package/node_modules/deepmerge/changelog.md +167 -0
  45. package/node_modules/deepmerge/dist/cjs.js +133 -0
  46. package/node_modules/deepmerge/dist/umd.js +139 -0
  47. package/node_modules/deepmerge/index.d.ts +20 -0
  48. package/node_modules/deepmerge/index.js +106 -0
  49. package/node_modules/deepmerge/license.txt +21 -0
  50. package/node_modules/deepmerge/package.json +42 -0
  51. package/node_modules/deepmerge/readme.md +264 -0
  52. package/node_modules/deepmerge/rollup.config.js +22 -0
  53. package/node_modules/npmlog/LICENSE.md +20 -0
  54. package/node_modules/npmlog/README.md +216 -0
  55. package/node_modules/npmlog/lib/log.js +400 -0
  56. package/node_modules/npmlog/package.json +52 -0
  57. package/nohoist.sh +11 -0
  58. package/package.json +3 -2
package/.jsii CHANGED
@@ -3941,7 +3941,7 @@
3941
3941
  },
3942
3942
  "description": "Core CDK Construct for patterns library",
3943
3943
  "homepage": "https://github.com/awslabs/aws-solutions-constructs.git",
3944
- "jsiiVersion": "5.7.7 (build 79515e6)",
3944
+ "jsiiVersion": "5.7.8 (build 2bc6834)",
3945
3945
  "license": "Apache-2.0",
3946
3946
  "metadata": {
3947
3947
  "jsii": {
@@ -9179,6 +9179,6 @@
9179
9179
  "symbolId": "lib/waf-helper:WafWebAclProps"
9180
9180
  }
9181
9181
  },
9182
- "version": "2.78.0",
9183
- "fingerprint": "tbt51vma/pM55hjMkatIV6gOiHEse4XLSJxNzdGNVs0="
9182
+ "version": "2.78.1",
9183
+ "fingerprint": "87r/wOtlRONnlL30ZPZHeLJXrdXaq+svkgIgpO62BlE="
9184
9184
  }
@@ -0,0 +1,76 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ working_directory: ~/repo
5
+ docker:
6
+ - image: circleci/node:8.11.3
7
+ steps:
8
+ - checkout
9
+ - run:
10
+ name: authorize npm
11
+ command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
12
+ - restore_cache:
13
+ key: dependency-cache-{{ checksum "package.json" }}
14
+ - run:
15
+ name: run npm install
16
+ command: npm install
17
+ - save_cache:
18
+ key: dependency-cache-{{ checksum "package.json" }}
19
+ paths:
20
+ - ./node_modules
21
+ - run: mkdir ~/junit
22
+ - run:
23
+ name: build & test
24
+ command: npm run ci
25
+ when: always
26
+ - run: cp test-results.xml ~/junit/test-results.xml
27
+ - store_test_results:
28
+ path: ~/junit
29
+ - store_artifacts:
30
+ path: ~/junit
31
+
32
+ build_deploy_npm:
33
+ working_directory: ~/repo
34
+ docker:
35
+ - image: circleci/node:8.11.3
36
+ steps:
37
+ - checkout
38
+ - run:
39
+ name: authorize npm
40
+ command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
41
+ - restore_cache:
42
+ key: dependency-cache-{{ checksum "package.json" }}
43
+ - run:
44
+ name: run npm install
45
+ command: npm install
46
+ - save_cache:
47
+ key: dependency-cache-{{ checksum "package.json" }}
48
+ paths:
49
+ - ./node_modules
50
+ - run: mkdir ~/junit
51
+ - run:
52
+ name: build & test
53
+ command: npm run ci
54
+ when: always
55
+ - run: cp test-results.xml ~/junit/test-results.xml
56
+ - store_test_results:
57
+ path: ~/junit
58
+ - store_artifacts:
59
+ path: ~/junit
60
+ - run:
61
+ name: publish package to npm
62
+ command: npm publish
63
+
64
+ workflows:
65
+ version: 2
66
+ build_deploy:
67
+ jobs:
68
+ - build:
69
+ context: secrets
70
+ - build_deploy_npm:
71
+ context: secrets
72
+ filters:
73
+ tags:
74
+ only: /.*/
75
+ branches:
76
+ ignore: /.*/
@@ -0,0 +1,72 @@
1
+ {
2
+ "parserOptions": {
3
+ "sourceType": "module"
4
+ },
5
+ "env": {
6
+ "node": true,
7
+ "browser": true
8
+ },
9
+ "extends": "eslint:recommended",
10
+ "rules": {
11
+ "no-alert": 2,
12
+ "no-array-constructor": 2,
13
+ "no-caller": 2,
14
+ "no-catch-shadow": 2,
15
+ "no-eval": 2,
16
+ "no-extend-native": 2,
17
+ "no-extra-bind": 2,
18
+ "no-implied-eval": 2,
19
+ "no-iterator": 2,
20
+ "no-label-var": 2,
21
+ "no-labels": 2,
22
+ "no-lone-blocks": 2,
23
+ "no-loop-func": 2,
24
+ "no-multi-spaces": 2,
25
+ "no-multi-str": 2,
26
+ "no-native-reassign": 2,
27
+ "no-new": 2,
28
+ "no-new-func": 2,
29
+ "no-new-object": 2,
30
+ "no-new-wrappers": 2,
31
+ "no-octal-escape": 2,
32
+ "no-process-exit": 2,
33
+ "no-proto": 2,
34
+ "no-return-assign": 2,
35
+ "no-script-url": 2,
36
+ "no-sequences": 2,
37
+ "no-shadow": 2,
38
+ "no-shadow-restricted-names": 2,
39
+ "no-spaced-func": 2,
40
+ "no-trailing-spaces": 2,
41
+ "no-undef-init": 2,
42
+ "no-underscore-dangle": 0,
43
+ "no-unused-expressions": 2,
44
+ "no-use-before-define": 2,
45
+ "no-with": 2,
46
+ "camelcase": 1,
47
+ "comma-spacing": 2,
48
+ "consistent-return": 2,
49
+ "curly": [ 2, "all" ],
50
+ "dot-notation": [ 2, { "allowKeywords": true } ],
51
+ "eol-last": 2,
52
+ "no-extra-parens": [ 2, "functions" ],
53
+ "eqeqeq": 2,
54
+ "keyword-spacing": [ 2, { "before": true, "after": true } ],
55
+ "key-spacing": [ 2, { "beforeColon": false, "afterColon": true } ],
56
+ "new-cap": 2,
57
+ "new-parens": 2,
58
+ "quotes": [ 2, "single" ],
59
+ "semi": 2,
60
+ "semi-spacing": [ 2, { "before": false, "after": true } ],
61
+ "space-infix-ops": 2,
62
+ "space-unary-ops": [ 2, { "words": true, "nonwords": false } ],
63
+ "strict": [ 2, "global" ],
64
+ "yoda": [ 2, "never" ]
65
+ },
66
+ "overrides": [
67
+ {
68
+ "files": [ "*.js", "test/*.js" ],
69
+ "excludedFiles": "examples/*.js"
70
+ }
71
+ ]
72
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "node",
9
+ "request": "launch",
10
+ "name": "Launch Program",
11
+ "program": "${workspaceFolder}/examples/array-change.js"
12
+ },
13
+ {
14
+ "name": "Run mocha",
15
+ "type": "node",
16
+ "request": "launch",
17
+ "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
18
+ "stopOnEntry": false,
19
+ "args": [
20
+ "test/**/*.js",
21
+ "--no-timeouts"
22
+ ],
23
+ "cwd": "${workspaceRoot}",
24
+ "runtimeExecutable": null,
25
+ "env": {
26
+ "NODE_ENV": "testing"
27
+ }
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+ // for the documentation about the tasks.json format
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "npm",
8
+ "script": "build",
9
+ "problemMatcher": []
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,63 @@
1
+ # deep-diff Change Log
2
+
3
+ **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.
4
+
5
+ ## Log
6
+
7
+ `1.0.2` - 2018-08-10
8
+
9
+ * Support for react-native environment - Thanks @xanderberkein
10
+
11
+ `1.0.0` - 2018-04-18
12
+
13
+ * reverted to [UMD style module](https://github.com/umdjs/umd) rather than the ES6 style, which evidently, broke lots of people's previously working code.
14
+ * fixed some bugs... see `examples/issue-XXx.js` for each issue I believe is fixed in this version.
15
+ * Closed:
16
+ * [#63 diff of equal objects should return empty array](https://github.com/flitbit/diff/issues/63)
17
+ * [#115 Remove second argument of applyChange from public api](https://github.com/flitbit/diff/issues/115)
18
+ * Resolved:
19
+ * [#78 FeatureRequest: change the diff of array elements (or add such an option)](https://github.com/flitbit/diff/issues/78)
20
+ * Fixed:
21
+ * [#47 Deleting Array elements](https://github.com/flitbit/diff/issues/47)
22
+ * [#111 Crash when comparing two undefined](https://github.com/flitbit/diff/issues/111)
23
+
24
+ `0.3.8` - 2017-05-03
25
+
26
+ * reconciled recently introduced difference between `index.es.js` and `index.js`
27
+ * improved npm commands for more reliable contributions
28
+ * added a few notes to README regarding contributing.
29
+
30
+ `0.3.7` - 2017-05-01
31
+
32
+ * fixed issue #98 by merging @sberan's pull request #99 — better handling of property with `undefined` value existing on either operand. Unit tests supplied.
33
+
34
+ `0.3.6` - 2017-04-25 — Fixed, closed lingering issues:
35
+
36
+ * fixed #74 — comparing objects with longer cycles
37
+ * fixed #70 — was not properly detecting a deletion when a property on the operand (lhs) had a value of `undefined` and was _undefined_ on the comparand (rhs). :o).
38
+ * WARNING! [Still broken when importing in Typescript](https://github.com/flitbit/diff/issues/97).
39
+
40
+ `0.3.5` - 2017-04-23 — Rolled up recent fixes; patches:
41
+
42
+ * @stevemao — #79, #80: now testing latest version of node4
43
+ * @mortonfox — #85: referencing mocha's new home
44
+ * @tdebarochez — #90: fixed error when .toString not a function
45
+ * @thiamsantos — #92, #93: changed module system for improved es2015 modules. WARNING! [This PR broke importing `deep-diff` in Typescript as reported by @kgentes in #97](https://github.com/flitbit/diff/issues/97)
46
+
47
+ `0.3.4` - Typescript users, reference this version until #97 is fixed!
48
+
49
+ `0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
50
+
51
+ `0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
52
+
53
+ `0.3.2` - Resolves #46; support more robust filters by including `lhs` and `rhs` in the filter callback. By @Orlando80
54
+
55
+ `0.3.1` - Better type checking by @Drinks, UMD wrapper by @SimenB. Now certifies against nodejs 12 and iojs (Thanks @SimenB).
56
+
57
+ `0.2.0` - [Fixes Bug #17](https://github.com/flitbit/diff/issues/17), [Fixes Bug #19](https://github.com/flitbit/diff/issues/19), [Enhancement #21](https://github.com/flitbit/diff/issues/21) Applying changes that are properly structured can now be applied as a change (no longer requires typeof Diff) - supports differences being applied after round-trip serialization to JSON format. Prefilter now reports the path of all changes - it was not showing a path for arrays and anything in the structure below (reported by @ravishvt).
58
+
59
+ *Breaking Change* – The structure of change records for differences below an array element has changed. Array indexes are now reported as numeric elements in the `path` if the changes is merely edited (an `E` kind). Changes of kind `A` (array) are only reported for changes in the terminal array itself and will have a nested `N` (new) item or a nested `D` (deleted) item.
60
+
61
+ `0.1.7` - [Enhancement #11](https://github.com/flitbit/diff/issues/11) Added the ability to filter properties that should not be analyzed while calculating differences. Makes `deep-diff` more usable with frameworks that attach housekeeping properties to existing objects. AngularJS does this, and the new filter ability should ease working with it.
62
+
63
+ `0.1.6` - Changed objects within nested arrays can now be applied. They were previously recording the changes appropriately but `applyDiff` would error. Comparison of `NaN` works more sanely - comparison to number shows difference, comparison to another `Nan` does not.
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2011-2018 Phillip Clark
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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,EACPQ,YAAY,EACZC,UAAU,EACVC,cAAc,KAKpB,SAASC,EAAKC,EAAMC,GAClBT,OAAOU,eAAeC,KAAM,OAAQ,CAClCR,MAAOK,EACPJ,YAAY,IAEVK,GAAQA,EAAKG,QACfZ,OAAOU,eAAeC,KAAM,OAAQ,CAClCR,MAAOM,EACPL,YAAY,IAKlB,SAASS,EAASJ,EAAMK,EAAQX,GAC9BU,EAASf,OAAOiB,KAAKJ,KAAM,IAAKF,GAChCT,OAAOU,eAAeC,KAAM,MAAO,CACjCR,MAAOW,EACPV,YAAY,IAEdJ,OAAOU,eAAeC,KAAM,MAAO,CACjCR,MAAOA,EACPC,YAAY,IAKhB,SAASY,EAAQP,EAAMN,GACrBa,EAAQlB,OAAOiB,KAAKJ,KAAM,IAAKF,GAC/BT,OAAOU,eAAeC,KAAM,MAAO,CACjCR,MAAOA,EACPC,YAAY,IAKhB,SAASa,EAAYR,EAAMN,GACzBc,EAAYnB,OAAOiB,K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,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
+