Skip to content

Commit 7ed5c74

Browse files
committed
plugins doc
1 parent 566e086 commit 7ed5c74

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Diff & patch JavaScript objects
1212

1313
- min+gzipped < 6KB
1414
- browser (```/build/bundle.js```) and server (eg. node.js)
15-
- includes [google-diff_match_patch](http://code.google.com/p/google-diff-match-patch/) for long text diffs (diff at characther level)
15+
- includes [google-diff-match-patch](http://code.google.com/p/google-diff-match-patch/) for long text diffs (diff at characther level)
1616
- smart array diffing using [LCS](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem), ***IMPORTANT NOTE:*** to match objects inside an array you ***must*** provide an ```objectHash``` function, check [Array diff documentation](docs/arrays.md)
1717
- reverse a delta
1818
- unpatch (eg. revert object to its original state using a delta)
@@ -187,9 +187,9 @@ var jsondiffpatch = require('jsondiffpatch').create(options);
187187
bower install jsondiffpatch
188188
```
189189

190-
bundles to include are on the ```/build``` folder:
190+
brower bundles are in the ```/build``` folder (run ```make``` or ```gulp``` to generate these):
191191
- bundle.js main bundle
192-
- bundle.full.js includes diff_match_patch library for text diffs
192+
- bundle.full.js includes [google-diff-match-patch](http://code.google.com/p/google-diff-match-patch/) library for text diffs
193193
- formatters.js includes builtin formatters (only those useful in a browser)
194194

195195
(all these include minified versions)
@@ -242,4 +242,11 @@ npm install -g jsondiffpatch
242242
jsondiffpatch ./demo/left.json ./demo/right.json
243243
```
244244

245-
![console_demo!](demo/consoledemo.png)
245+
![console_demo!](demo/consoledemo.png)
246+
247+
Plugins
248+
-------
249+
250+
```diff()```, ```patch()``` and ```reverse()``` functions are implemented using a pipes &filters pattern, making it extremely customizable by adding or replacing filters on a pipe.
251+
252+
Check [Plugins documentation](docs/formatters.md) for more info.

docs/plugins.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```diff()```, ```patch()``` and ```reverse()``` functions are implemented using a pipes &filters pattern, making it extremely customizable by adding or replacing filters on a pipe.
2+
3+
Some examples of what you can acheive writing your own filter:
4+
- diff special custom objects (eg. DOM nodes, native objects, functions, RegExp, node.js streams?)
5+
- ignore parts of the graph using any custom rule (type, path, flags)
6+
- change diff strategy in specific parts of the graph, eg. rely on change tracking info for Knockout.js tracked objects
7+
- implement custom diff mechanisms, like relative numeric deltas
8+
- suprise me! :)
9+
10+
Check the ```/src/filters``` folder for more example code.

0 commit comments

Comments
 (0)