@broofa/merge
Advanced tools
Comparing version 1.0.2 to 1.0.4
@@ -6,9 +6,9 @@ /** | ||
function merge(before, after) { | ||
// Identical? | ||
// Same object | ||
if (before === after) return before; | ||
// Undefined or null? | ||
// Undefined or null | ||
if (before == null || after == null) return after; | ||
// Different types? | ||
// Different types | ||
if (before.constructor !== after.constructor) return after; | ||
@@ -15,0 +15,0 @@ |
{ | ||
"name": "@broofa/merge", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Merge immutable JSON data structures to allow for identity (===) comparisons on deeply-equal subtrees", | ||
"main": "index.js", | ||
"dependencies": { | ||
"mocha": "^5.2.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"mocha": "^5.2.0", | ||
"runmd": "^1.0.1" | ||
@@ -15,8 +14,7 @@ }, | ||
"md": "runmd --watch --output=README.md src/README_js.md", | ||
"prepare": "runmd --output=README.md src/README_js.md" | ||
"prepare": "npm test && runmd --output=README.md src/README_js.md" | ||
}, | ||
"homepage": "https://github.com/broofa/BroofaJS/merge", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/broofa/BroofaJS" | ||
"url": "https://github.com/broofa/BroofaJS/tree/master/merge" | ||
}, | ||
@@ -23,0 +21,0 @@ "keywords": [ |
@@ -7,13 +7,19 @@ <!-- | ||
Merge immutable model state (or any data structure, really), preserving references to unchanged nodes. This | ||
allows for `===` operation to determine where state has changed. (Useful when | ||
dealing with immutable data models such as React+Redux, where `===` is used for | ||
exactly this purpose.) | ||
Merge immutable model state (or any data structure, really), preserving references to unchanged nodes, such that the `===` operation can be used to determine where state has changed. (Useful when dealing with immutable data models such as React+Redux, where `===` is used for exactly this purpose.) | ||
In practical terms, where `state = merge(before, after)` the returned `state` object has the following properties: | ||
Specifically, given | ||
* `assert.deepEqual(state, after)` will always be true | ||
* `state[X] === before[X]` will be true where `deepEqual(before[X], after[X])` | ||
* `state[X] === after[X]` will be true where `after[X]` replaces all `before[X]` state | ||
* Two JSON data structures, `before` and `after` | ||
* `state = merge(before, after)` | ||
Then: | ||
* `assert.deepEqual(state, after)` always passes | ||
And for any path, `[X]`, to an Object or Array within `state`: | ||
* `state[X] === before[X]` where `assert.deepEqual(before[X], state[X])` passes | ||
* `state[X] === after[X]` where no part of `after[X]` is equal to `before[X]` | ||
* `state[X] === (new Object/Array)` when some, but not all state w/in `[X]` has changed | ||
## Installation | ||
@@ -20,0 +26,0 @@ |
@@ -7,13 +7,19 @@ ```javascript --hide | ||
Merge immutable model state (or any data structure, really), preserving references to unchanged nodes. This | ||
allows for `===` operation to determine where state has changed. (Useful when | ||
dealing with immutable data models such as React+Redux, where `===` is used for | ||
exactly this purpose.) | ||
Merge immutable model state (or any data structure, really), preserving references to unchanged nodes, such that the `===` operation can be used to determine where state has changed. (Useful when dealing with immutable data models such as React+Redux, where `===` is used for exactly this purpose.) | ||
In practical terms, where `state = merge(before, after)` the returned `state` object has the following properties: | ||
Specifically, given | ||
* `assert.deepEqual(state, after)` will always be true | ||
* `state[X] === before[X]` will be true where `deepEqual(before[X], after[X])` | ||
* `state[X] === after[X]` will be true where `after[X]` replaces all `before[X]` state | ||
* Two JSON data structures, `before` and `after` | ||
* `state = merge(before, after)` | ||
Then: | ||
* `assert.deepEqual(state, after)` always passes | ||
And for any path, `[X]`, to an Object or Array within `state`: | ||
* `state[X] === before[X]` where `assert.deepEqual(before[X], state[X])` passes | ||
* `state[X] === after[X]` where no part of `after[X]` is equal to `before[X]` | ||
* `state[X] === (new Object/Array)` when some, but not all state w/in `[X]` has changed | ||
## Installation | ||
@@ -20,0 +26,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7229
0
65
2
- Removedmocha@^5.2.0
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbrowser-stdout@1.3.1(transitive)
- Removedcommander@2.15.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddebug@3.1.0(transitive)
- Removeddiff@3.5.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.1.2(transitive)
- Removedgrowl@1.10.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhe@1.1.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedminimatch@3.0.4(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.5.1(transitive)
- Removedmocha@5.2.0(transitive)
- Removedms@2.0.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedsupports-color@5.4.0(transitive)
- Removedwrappy@1.0.2(transitive)