Skip to content

Commit 081e108

Browse files
committed
Merge branch 'master' into fixes
2 parents 0e3c27a + e0f5e22 commit 081e108

10 files changed

Lines changed: 412 additions & 217 deletions

File tree

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
node-version: 'lts/*'
1818
cache: 'npm'
1919
- run: npm ci
20+
- run: npm run format-check
21+
- run: npm run lint
22+
working-directory: ./packages/jsondiffpatch
2023
- run: npm run build
2124
working-directory: ./packages/jsondiffpatch
2225
- run: npm run test
2326
working-directory: ./packages/jsondiffpatch
24-
- run: npm run lint
25-
working-directory: ./packages/jsondiffpatch
26-
- run: npm run format-check
2727
- run: npm run start
2828
working-directory: ./demos/console-demo
2929
- run: npm run build

README.md

Lines changed: 7 additions & 5 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: [

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

package-lock.json

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsondiffpatch/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsondiffpatch",
3-
"version": "0.6.2",
3+
"version": "0.7.1",
44
"author": "Benjamin Eidelman <beneidel@gmail.com>",
55
"description": "Diff & Patch for Javascript objects",
66
"contributors": [

packages/jsondiffpatch/src/formatters/jsonpatch-apply.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ export const applyJsonPatchRFC6902 = (
3636
result?: unknown;
3737
}[] = [];
3838

39-
console.debug('starting jsonpatch from', target);
40-
4139
patch.forEach((op) => {
4240
try {
43-
console.debug(`applying op`, op);
4441
switch (op.op) {
4542
case 'add':
4643
log.push({ result: add(target, op.path, op.value), op });
@@ -66,7 +63,6 @@ export const applyJsonPatchRFC6902 = (
6663
`operation not recognized: ${JSON.stringify(op as unknown)}`,
6764
);
6865
}
69-
console.debug(`result`, target);
7066
} catch (error) {
7167
rollback(
7268
target,

0 commit comments

Comments
 (0)