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: README.md
+8-12Lines changed: 8 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,15 +24,14 @@
24
24
- min+gzipped ~ 16KB
25
25
- browser and server (ESM-only)
26
26
- deep diff, use delta to patch
27
-
- (optionally) uses [google-diff-match-patch](http://code.google.com/p/google-diff-match-patch/) for long text diffs (diff at character level)
28
27
- 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 (this is how objects are matched, otherwise a dumb match by position is used). For more details, check [Array diff documentation](docs/arrays.md)
28
+
- (optionally) text diffing of long strings powered by [google-diff-match-patch](http://code.google.com/p/google-diff-match-patch/) (diff at character level)
29
29
- reverse a delta, unpatch (eg. revert object to its original state using a delta)
30
-
-simplistic, pure JSON, low footprint [delta format](docs/deltas.md)
31
-
- multiple output formatters:
32
-
-html (check it at the [Live Demo](https://jsondiffpatch.com))
33
-
-annotated json (html), makes the JSON delta format self-explained
30
+
-multiple output formats:
31
+
- pure JSON, low footprint [delta format](docs/deltas.md)
32
+
-annotated JSON (html), to help explain the format with annotations
33
+
-JSON Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902)), can generate patches, and also apply them
If two strings are compared and they are different, you will see as you expect:
106
106
107
-
```javascript
107
+
```ts
108
108
delta= ['some text', 'some text modified'];
109
109
```
110
110
111
111
But if both strings are long enough, [a text diffing algorithm](https://code.google.com/p/google-diff-match-patch/) will be used to efficiently detect changes in parts of the text.
112
112
113
113
You can modify the minimum length with:
114
114
115
-
```javascript
116
-
var customDiffPatch =jsondiffpatch.create({
115
+
```ts
116
+
const customDiffPatch =jsondiffpatch.create({
117
117
textDiff: {
118
118
minLength: 60, // default value
119
119
},
@@ -122,7 +122,7 @@ var customDiffPatch = jsondiffpatch.create({
Note: this patch method is atomic as specified by [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902#section-5). If any error occurs during patching, the `target` object is rolled back to its original state.
77
+
66
78
## Create one
67
79
68
80
Of course, first step to create a formatters is understanding the [delta format](deltas.md).
Copy file name to clipboardExpand all lines: docs/plugins.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Check the `/src/filters` folder for filter examples.
17
17
Here is an example to provide number differences in deltas (when left and right values are both numbers)
18
18
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).
0 commit comments