1
- var jsondiffpatch = require ( '../../dist/jsondiffpatch.cjs.js' ) ;
1
+ const jsondiffpatch = require ( '../../dist/jsondiffpatch.cjs.js' ) ;
2
2
3
- var instance = jsondiffpatch . create ( {
3
+ const instance = jsondiffpatch . create ( {
4
4
objectHash : function ( obj ) {
5
5
return obj . _id || obj . id || obj . name || JSON . stringify ( obj ) ;
6
- }
6
+ } ,
7
7
} ) ;
8
8
9
- var data = {
9
+ const data = {
10
10
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.' ,
27
35
28
36
surface : 17840000 ,
29
37
timezone : [ - 4 , - 2 ] ,
30
38
demographics : {
31
39
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
+ ] ,
33
47
} ,
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
+ ] ,
96
133
} ;
97
134
98
- var left = JSON . parse ( ( JSON . stringify ( data ) ) , jsondiffpatch . dateReviver ) ;
135
+ let left = JSON . parse ( JSON . stringify ( data ) , jsondiffpatch . dateReviver ) ;
99
136
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.' ) ;
101
140
data . languages [ 2 ] = 'inglés' ;
102
141
data . countries . pop ( ) ;
103
142
data . countries . pop ( ) ;
104
143
data . countries [ 0 ] . capital = 'Rawson' ;
105
144
data . countries . push ( {
106
145
name : 'Antártida' ,
107
- unasur : false
146
+ unasur : false ,
108
147
} ) ;
109
148
110
149
// modify and move
@@ -117,6 +156,6 @@ delete data.surface;
117
156
data . spanishName = 'Sudamérica' ;
118
157
data . demographics . population += 2342 ;
119
158
120
- var right = data ;
121
- var delta = instance . diff ( left , right ) ;
159
+ let right = data ;
160
+ let delta = instance . diff ( left , right ) ;
122
161
jsondiffpatch . console . log ( delta ) ;
0 commit comments