Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@broofa/merge

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@broofa/merge - npm Package Compare versions

Comparing version 1.0.2 to 1.0.4

6

index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc