immutable-merge-patch

1.0.1 • Public • Published

immutable-merge-patch

An implementation of RFC 7396 (JSON Merge Patch) for Immutable.js Maps.

Thoroughly tested with full code coverage using Mocha and Istanbul.

Installation

npm install --save immutable-merge-patch

Usage

var Immutable = require("immutable");
var immutableMergePatch = require("immutable-merge-patch");
 
var a = Map({
    a: 1,
    b: 2,
    c: 3
});
var b = Map({
    a: 1,
    b: 5,
    c: "some string"
});
 
var diff = immutableMergePatch.generate(a, b);
// diff = Map { b: 5, c: "some string" }
var c = immutableMergePatch.apply(a, diff);
// c.equals(a) === true

Limitations / features not specified in RFC 7396

  • Non-string keys are currently totally ignored. (Have a reason for this to change? Open an issue and I'll consider it.)
  • The generate function only recurses into Immutable.Map objects, not plain JavaScript objects.
  • If the Maps passed into generate() are OrderedMaps, an OrderedMap is returned, with the keys inheriting their order from the first parameter where possible.

License

immutable-merge-patch is licensed under the MIT License.

P.S. It's also forthebadge. ;)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i immutable-merge-patch

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • drmercer