Skip to content

Commit 387eb56

Browse files
committed
linting and test watch
1 parent 736b411 commit 387eb56

15 files changed

+2018
-551
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ node_modules
33
build
44
.git
55
coverage
6-
flow-typed
76
dist

.jscsrc

Lines changed: 0 additions & 74 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/jsondiffpatch

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#!/usr/bin/env node
22

3-
var jsondiffpatch = require('../build/jsondiffpatch.cjs');
3+
const jsondiffpatch = require('../build/jsondiffpatch.cjs');
44

5-
var fs = require('fs');
5+
const fs = require('fs');
66

7-
var fileLeft = process.argv[2], fileRight = process.argv[3];
7+
const fileLeft = process.argv[2];
8+
const fileRight = process.argv[3];
89

9-
if (!fileLeft || !fileRight){
10-
console.log('\n USAGE: jsondiffpatch left.json right.json');
11-
return;
10+
if (!fileLeft || !fileRight) {
11+
console.log('\n USAGE: jsondiffpatch left.json right.json');
12+
return;
1213
}
1314

14-
var left = JSON.parse(fs.readFileSync(fileLeft));
15-
var right = JSON.parse(fs.readFileSync(fileRight));
15+
const left = JSON.parse(fs.readFileSync(fileLeft));
16+
const right = JSON.parse(fs.readFileSync(fileRight));
1617

17-
var delta = jsondiffpatch.diff(left, right);
18+
const delta = jsondiffpatch.diff(left, right);
1819
jsondiffpatch.console.log(delta);

docs/demo/consoledemo.js

Lines changed: 127 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,149 @@
1-
var jsondiffpatch = require('../../dist/jsondiffpatch.cjs.js');
1+
const jsondiffpatch = require('../../dist/jsondiffpatch.cjs.js');
22

3-
var instance = jsondiffpatch.create({
3+
const instance = jsondiffpatch.create({
44
objectHash: function(obj) {
55
return obj._id || obj.id || obj.name || JSON.stringify(obj);
6-
}
6+
},
77
});
88

9-
var data = {
9+
const data = {
1010
name: 'South America',
11-
summary: 'South America (Spanish: América del Sur, Sudamérica or Suramérica; Portuguese: América do Sul;' +
12-
' Quechua and Aymara: Urin Awya Yala; Guarani: Ñembyamérika; Dutch: Zuid-Amerika; French: Amérique' +
13-
' du Sud) is a continent situated in the Western Hemisphere, mostly in the Southern Hemisphere,' +
14-
' with a relatively small portion in the Northern Hemisphere. The continent is also considered a' +
15-
' subcontinent of the Americas.[2][3] It is bordered on the west by the Pacific Ocean and on the ' +
16-
'north and east by the Atlantic Ocean; North America and the Caribbean Sea lie to the northwest. ' +
17-
'It includes twelve countries: Argentina, Bolivia, Brazil, Chile, Colombia, Ecuador, Guyana, Paraguay' +
18-
', Peru, Suriname, Uruguay, and Venezuela. The South American nations that border the Caribbean ' +
19-
'Sea—including Colombia, Venezuela, Guyana, Suriname, as well as French Guiana, which is an overseas' +
20-
' region of France—are also known as Caribbean South America. South America has an area of 17,840,000' +
21-
' square kilometers (6,890,000 sq mi). Its population as of 2005 has been estimated at more than ' +
22-
'371,090,000. South America ranks fourth in area (after Asia, Africa, and North America) and fifth ' +
23-
'in population (after Asia, Africa, Europe, and North America). The word America was coined in 1507 by' +
24-
' cartographers Martin Waldseemüller and Matthias Ringmann, after Amerigo Vespucci, who was the first ' +
25-
'European to suggest that the lands newly discovered by Europeans were not India, but a New World ' +
26-
'unknown to Europeans.',
11+
summary:
12+
'South America (Spanish: América del Sur, Sudamérica or Suramérica;' +
13+
' Portuguese: América do Sul; Quechua and Aymara: Urin Awya Yala;' +
14+
' Guarani: Ñembyamérika; Dutch: Zuid-Amerika; French: Amérique du Sud)' +
15+
' is a continent situated in the Western Hemisphere, mostly in the' +
16+
' Southern Hemisphere, with a relatively small portion in the Northern' +
17+
' Hemisphere. The continent is also considered a subcontinent of the' +
18+
' Americas.[2][3] It is bordered on the west by the Pacific Ocean and' +
19+
' on the north and east by the Atlantic Ocean; North America and the' +
20+
' Caribbean Sea lie to the northwest. It includes twelve countries: ' +
21+
'Argentina, Bolivia, Brazil, Chile, Colombia, Ecuador, Guyana, Paraguay' +
22+
', Peru, Suriname, Uruguay, and Venezuela. The South American nations' +
23+
' that border the Caribbean Sea—including Colombia, Venezuela, Guyana,' +
24+
' Suriname, as well as French Guiana, which is an overseas region of' +
25+
' France—are also known as Caribbean South America. South America has' +
26+
' an area of 17,840,000 square kilometers (6,890,000 sq mi).' +
27+
' Its population as of 2005 has been estimated at more than 371,090,000.' +
28+
' South America ranks fourth in area (after Asia, Africa, and' +
29+
' North America) and fifth in population (after Asia, Africa,' +
30+
' Europe, and North America). The word America was coined in 1507 by' +
31+
' cartographers Martin Waldseemüller and Matthias Ringmann, after' +
32+
' Amerigo Vespucci, who was the first European to suggest that the' +
33+
' lands newly discovered by Europeans were not India, but a New World' +
34+
' unknown to Europeans.',
2735

2836
surface: 17840000,
2937
timezone: [-4, -2],
3038
demographics: {
3139
population: 385742554,
32-
largestCities: ['São Paulo', 'Buenos Aires', 'Rio de Janeiro', 'Lima', 'Bogotá']
40+
largestCities: [
41+
'São Paulo',
42+
'Buenos Aires',
43+
'Rio de Janeiro',
44+
'Lima',
45+
'Bogotá',
46+
],
3347
},
34-
languages: ['spanish', 'portuguese', 'english', 'dutch', 'french', 'quechua', 'guaraní', 'aimara', 'mapudungun'],
35-
countries: [{
36-
name: 'Argentina',
37-
capital: 'Buenos Aires',
38-
independence: new Date(1816, 6, 9),
39-
unasur: true
40-
}, {
41-
name: 'Bolivia',
42-
capital: 'La Paz',
43-
independence: new Date(1825, 7, 6),
44-
unasur: true
45-
}, {
46-
name: 'Brazil',
47-
capital: 'Brasilia',
48-
independence: new Date(1822, 8, 7),
49-
unasur: true
50-
}, {
51-
name: 'Chile',
52-
capital: 'Santiago',
53-
independence: new Date(1818, 1, 12),
54-
unasur: true
55-
}, {
56-
name: 'Colombia',
57-
capital: 'Bogotá',
58-
independence: new Date(1810, 6, 20),
59-
unasur: true
60-
}, {
61-
name: 'Ecuador',
62-
capital: 'Quito',
63-
independence: new Date(1809, 7, 10),
64-
unasur: true
65-
}, {
66-
name: 'Guyana',
67-
capital: 'Georgetown',
68-
independence: new Date(1966, 4, 26),
69-
unasur: true
70-
}, {
71-
name: 'Paraguay',
72-
capital: 'Asunción',
73-
independence: new Date(1811, 4, 14),
74-
unasur: true
75-
}, {
76-
name: 'Peru',
77-
capital: 'Lima',
78-
independence: new Date(1821, 6, 28),
79-
unasur: true
80-
}, {
81-
name: 'Suriname',
82-
capital: 'Paramaribo',
83-
independence: new Date(1975, 10, 25),
84-
unasur: true
85-
}, {
86-
name: 'Uruguay',
87-
capital: 'Montevideo',
88-
independence: new Date(1825, 7, 25),
89-
unasur: true
90-
}, {
91-
name: 'Venezuela',
92-
capital: 'Caracas',
93-
independence: new Date(1811, 6, 5),
94-
unasur: true
95-
}]
48+
languages: [
49+
'spanish',
50+
'portuguese',
51+
'english',
52+
'dutch',
53+
'french',
54+
'quechua',
55+
'guaraní',
56+
'aimara',
57+
'mapudungun',
58+
],
59+
countries: [
60+
{
61+
name: 'Argentina',
62+
capital: 'Buenos Aires',
63+
independence: new Date(1816, 6, 9),
64+
unasur: true,
65+
},
66+
{
67+
name: 'Bolivia',
68+
capital: 'La Paz',
69+
independence: new Date(1825, 7, 6),
70+
unasur: true,
71+
},
72+
{
73+
name: 'Brazil',
74+
capital: 'Brasilia',
75+
independence: new Date(1822, 8, 7),
76+
unasur: true,
77+
},
78+
{
79+
name: 'Chile',
80+
capital: 'Santiago',
81+
independence: new Date(1818, 1, 12),
82+
unasur: true,
83+
},
84+
{
85+
name: 'Colombia',
86+
capital: 'Bogotá',
87+
independence: new Date(1810, 6, 20),
88+
unasur: true,
89+
},
90+
{
91+
name: 'Ecuador',
92+
capital: 'Quito',
93+
independence: new Date(1809, 7, 10),
94+
unasur: true,
95+
},
96+
{
97+
name: 'Guyana',
98+
capital: 'Georgetown',
99+
independence: new Date(1966, 4, 26),
100+
unasur: true,
101+
},
102+
{
103+
name: 'Paraguay',
104+
capital: 'Asunción',
105+
independence: new Date(1811, 4, 14),
106+
unasur: true,
107+
},
108+
{
109+
name: 'Peru',
110+
capital: 'Lima',
111+
independence: new Date(1821, 6, 28),
112+
unasur: true,
113+
},
114+
{
115+
name: 'Suriname',
116+
capital: 'Paramaribo',
117+
independence: new Date(1975, 10, 25),
118+
unasur: true,
119+
},
120+
{
121+
name: 'Uruguay',
122+
capital: 'Montevideo',
123+
independence: new Date(1825, 7, 25),
124+
unasur: true,
125+
},
126+
{
127+
name: 'Venezuela',
128+
capital: 'Caracas',
129+
independence: new Date(1811, 6, 5),
130+
unasur: true,
131+
},
132+
],
96133
};
97134

98-
var left = JSON.parse((JSON.stringify(data)), jsondiffpatch.dateReviver);
135+
let left = JSON.parse(JSON.stringify(data), jsondiffpatch.dateReviver);
99136

100-
data.summary = data.summary.replace('Brazil', 'Brasil').replace('also known as', 'a.k.a.');
137+
data.summary = data.summary
138+
.replace('Brazil', 'Brasil')
139+
.replace('also known as', 'a.k.a.');
101140
data.languages[2] = 'inglés';
102141
data.countries.pop();
103142
data.countries.pop();
104143
data.countries[0].capital = 'Rawson';
105144
data.countries.push({
106145
name: 'Antártida',
107-
unasur: false
146+
unasur: false,
108147
});
109148

110149
// modify and move
@@ -117,6 +156,6 @@ delete data.surface;
117156
data.spanishName = 'Sudamérica';
118157
data.demographics.population += 2342;
119158

120-
var right = data;
121-
var delta = instance.diff(left, right);
159+
let right = data;
160+
let delta = instance.diff(left, right);
122161
jsondiffpatch.console.log(delta);

0 commit comments

Comments
 (0)