Skip to content

Commit 3892eea

Browse files
authored
Merge pull request #403 from benjamine/vnext
docs: fix readme and demo examples
2 parents 2d3cd46 + bc5a30a commit 3892eea

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
- reverse a delta, unpatch (eg. revert object to its original state using a delta)
3030
- multiple output formats:
3131
- pure JSON, low footprint [delta format](docs/deltas.md)
32-
- annotated JSON (html), to help explain the format with annotations
32+
- <span style="background-color: #bbffbb; color: black;">visual</span> <span style="background-color: #ffbbbb; color:black; text-decoration: line-through">diff</span> (html), see [demo](https://jsondiffpatch.com)
33+
- annotated JSON (html), to help explain the delta format with annotations
3334
- JSON Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902)), can generate patches, and also apply them
3435
- console (colored), try running `./node_modules/.bin/jsondiffpatch left.json right.json`
3536
- write your own! check [Formatters documentation](docs/formatters.md)
@@ -44,20 +45,20 @@
4445

4546
as a CLI:
4647

47-
```sh
48+
``` sh
4849
npx jsondiffpatch https://jsondiffpatch.com/demo/left.json https://jsondiffpatch.com/demo/right.json
4950
```
5051

5152
![console_demo!](docs/demo/consoledemo.png)
5253

5354
or as a library:
5455

55-
```ts// sample data
56+
```ts
57+
// sample data
5658
const country = {
5759
name: 'Argentina',
5860
capital: 'Buenos Aires',
5961
independence: new Date(1816, 6, 9),
60-
unasur: true,
6162
};
6263

6364
// clone country, using dateReviver for Date objects
@@ -90,7 +91,8 @@ assert(delta2 === undefined);
9091

9192
Array diffing:
9293

93-
```ts// sample data
94+
```ts
95+
// sample data
9496
const country = {
9597
name: 'Argentina',
9698
cities: [
@@ -199,7 +201,8 @@ In a browser, you can load a bundle using a tool like [esm.sh](https://esm.sh) o
199201

200202
## Options
201203

202-
```tsimport * as jsondiffpatch from 'jsondiffpatch';
204+
```ts
205+
import * as jsondiffpatch from 'jsondiffpatch';
203206

204207
// Only import if you want text diffs using diff-match-patch
205208
import DiffMatchPatch from 'diff-match-patch';

demos/console-demo/demo.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as jsondiffpatch from 'jsondiffpatch/with-text-diffs';
21
import * as consoleFormatter from 'jsondiffpatch/formatters/console';
2+
import * as jsondiffpatch from 'jsondiffpatch/with-text-diffs';
33

44
const instance = jsondiffpatch.create({
55
objectHash: function (obj) {
@@ -24,7 +24,6 @@ interface Data {
2424
name: string;
2525
capital?: string;
2626
independence?: Date;
27-
unasur: boolean;
2827
population?: number;
2928
}[];
3029
spanishName?: string;
@@ -85,73 +84,61 @@ const data: Data = {
8584
name: 'Argentina',
8685
capital: 'Buenos Aires',
8786
independence: new Date(1816, 6, 9),
88-
unasur: true,
8987
},
9088
{
9189
name: 'Bolivia',
9290
capital: 'La Paz',
9391
independence: new Date(1825, 7, 6),
94-
unasur: true,
9592
},
9693
{
9794
name: 'Brazil',
9895
capital: 'Brasilia',
9996
independence: new Date(1822, 8, 7),
100-
unasur: true,
10197
},
10298
{
10399
name: 'Chile',
104100
capital: 'Santiago',
105101
independence: new Date(1818, 1, 12),
106-
unasur: true,
107102
},
108103
{
109104
name: 'Colombia',
110105
capital: 'Bogotá',
111106
independence: new Date(1810, 6, 20),
112-
unasur: true,
113107
},
114108
{
115109
name: 'Ecuador',
116110
capital: 'Quito',
117111
independence: new Date(1809, 7, 10),
118-
unasur: true,
119112
},
120113
{
121114
name: 'Guyana',
122115
capital: 'Georgetown',
123116
independence: new Date(1966, 4, 26),
124-
unasur: true,
125117
},
126118
{
127119
name: 'Paraguay',
128120
capital: 'Asunción',
129121
independence: new Date(1811, 4, 14),
130-
unasur: true,
131122
},
132123
{
133124
name: 'Peru',
134125
capital: 'Lima',
135126
independence: new Date(1821, 6, 28),
136-
unasur: true,
137127
},
138128
{
139129
name: 'Suriname',
140130
capital: 'Paramaribo',
141131
independence: new Date(1975, 10, 25),
142-
unasur: true,
143132
},
144133
{
145134
name: 'Uruguay',
146135
capital: 'Montevideo',
147136
independence: new Date(1825, 7, 25),
148-
unasur: true,
149137
},
150138
{
151139
name: 'Venezuela',
152140
capital: 'Caracas',
153141
independence: new Date(1811, 6, 5),
154-
unasur: true,
155142
},
156143
],
157144
};
@@ -167,7 +154,6 @@ data.countries.pop();
167154
data.countries[0].capital = 'Rawson';
168155
data.countries.push({
169156
name: 'Antártida',
170-
unasur: false,
171157
});
172158

173159
// modify and move

0 commit comments

Comments
 (0)