Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from jiyinyiyong/improve-docs
adding example to README
- Loading branch information
Showing
1 changed file
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
#Immutable Patch | ||
Immutable Patch | ||
==== | ||
|
||
Apply RFC 6902 style patches to Immutable.JS data structures, such as `Maps`, `Lists`, and `Sets`. | ||
Apply RFC 6902 style patches to Immutable.JS data structures, such as `Maps`, `Lists`, and `Sets`. | ||
|
||
### Getting Started | ||
|
||
You may get the module via npm: | ||
|
||
``` | ||
npm install immutablepatch | ||
``` | ||
|
||
And apply JSON patches to an immutable JSON object: | ||
|
||
```js | ||
var Immutable = require('immutable'); | ||
var patch = require('immutablepatch'); | ||
|
||
var list = Immutable.fromJS([1, 2, [3, 4]]); | ||
var ops = Immutable.fromJS([ | ||
{op: 'replace', path: '/2/1', value: 10} | ||
]); | ||
|
||
var result = patch(list, ops); | ||
// var expected = Immutable.fromJS([1, 2, [3, 10]]); | ||
``` | ||
|
||
You will probably need [`immutablediff`](https://github.com/intelie/immutable-js-diff) to generate diff operations. |