seamless-immutable-mergers
Advanced tools
Comparing version 3.0.2 to 4.0.0
{ | ||
"name": "seamless-immutable-mergers", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"description": "A collection of merger functions for seamless-immutable.", | ||
"main": "seamless-immutable-mergers.js", | ||
"dependencies": { | ||
"seamless-immutable": "~3.0.0" | ||
"seamless-immutable": "~4.0.2" | ||
}, | ||
"browserDependencies": { | ||
"seamless-immutable": "~3.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -13,0 +10,0 @@ "chai": "~1.9.2", |
@@ -95,2 +95,32 @@ seamless-immutable-mergers | ||
### ignoreArrayMerger | ||
This is a simple merger that instead of replacing an array with another keeps the original one. Example: | ||
```javascript | ||
var immutable = require("seamless-immutable"); | ||
var mergers = reuqire("seamless-immutable-mergers"); | ||
var immutableObject = immutable({ | ||
title: "one", | ||
items: [1, 2] | ||
}); | ||
var otherObject = { | ||
title: "two", | ||
items: [3, 4] | ||
}; | ||
var result = immutableObject.merge(otherObject, {merger: mergers.ignoreArrayMerger}); | ||
``` | ||
The result will be: | ||
```javascript | ||
{ | ||
title: "two", | ||
items: [1, 2] | ||
} | ||
``` | ||
### updatingByIdArrayMerger | ||
@@ -159,2 +189,5 @@ This is a merger that operates on arrays that contains objects with specified ids. It tries to merge each object in the target array with the object with the same id from the source array. Example: | ||
## Releases | ||
### 4.0.0 | ||
Added *ignoreArrayMerger*, updated to *[seamless-immutable](https://github.com/rtfeldman/seamless-immutable)* 4.0.2 and bumped the major version to be in sync. | ||
### 3.0.2 | ||
@@ -161,0 +194,0 @@ Fixed a bug in *updatingByIdArrayMerger* where a merge with an empty array would wipe the content of the current array. |
@@ -28,2 +28,8 @@ "use strict"; | ||
function ignoreArrayMerger(current, other) { | ||
if (!(current instanceof Array) || !(other instanceof Array)) return; | ||
return current; | ||
} | ||
function updatingByIdArrayMerger(current, other, config) { | ||
@@ -60,4 +66,5 @@ if (!(current instanceof Array) || !(other instanceof Array)) return; | ||
concatArrayMerger: concatArrayMerger, | ||
updatingByIdArrayMerger: updatingByIdArrayMerger, | ||
equalityArrayMerger: equalityArrayMerger | ||
equalityArrayMerger: equalityArrayMerger, | ||
ignoreArrayMerger: ignoreArrayMerger, | ||
updatingByIdArrayMerger: updatingByIdArrayMerger | ||
}; | ||
@@ -64,0 +71,0 @@ |
33462
10
502
205
+ Addedseamless-immutable@4.0.2(transitive)
- Removedseamless-immutable@3.0.0(transitive)
Updatedseamless-immutable@~4.0.2