You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins.md
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
Plugins
2
+
=======
3
+
1
4
```diff()```, ```patch()``` and ```reverse()``` functions are implemented using a pipes &filters pattern, making them extremely customizable by adding or replacing filters.
2
5
3
6
Some examples of what you can acheive writing your own filter:
@@ -7,4 +10,63 @@ Some examples of what you can acheive writing your own filter:
7
10
- implement custom diff mechanisms, like relative numeric deltas
8
11
- suprise me! :)
9
12
10
-
Check the ```/src/filters``` folder for more example code.
13
+
Check the ```/src/filters``` folder for code examples.
14
+
15
+
Example
16
+
------
17
+
18
+
Here is an example to provide number differences in deltas (when left and right values are both numbers)
19
+
This, way when diffing 2 numbers instead of obtaining ```[ oldValue, newValue ] ```, the difference between both values will be saved, this could be useful for counters simultaneously incremented in multiple client applications (patches that both increment a value would be combined, instead of failing with a conflict).
20
+
21
+
```javascript
22
+
var diffpatcher =jsondiffpatch.create();
23
+
varNUMERIC_DIFFERENCE=-8;
24
+
25
+
varnumericDiffFilter=function(context) {
26
+
if (typeofcontext.left==='number'&&typeofcontext.right==='number') {
0 commit comments