Skip to content

Commit 47a9882

Browse files
hygiene
1 parent 36df833 commit 47a9882

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

json2.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
json2.js
3-
2011-08-30
2+
http://www.JSON.org/json2.js
3+
2011-10-19
44
55
Public Domain.
66
@@ -146,7 +146,7 @@
146146
redistribute.
147147
*/
148148

149-
/*jslint evil: true, regexp: true, unparam: true */
149+
/*jslint evil: true, regexp: true */
150150

151151
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152152
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
@@ -176,13 +176,14 @@ if (!JSON) {
176176

177177
Date.prototype.toJSON = function (key) {
178178

179-
return isFinite(this.valueOf()) ?
180-
this.getUTCFullYear() + '-' +
181-
f(this.getUTCMonth() + 1) + '-' +
182-
f(this.getUTCDate()) + 'T' +
183-
f(this.getUTCHours()) + ':' +
184-
f(this.getUTCMinutes()) + ':' +
185-
f(this.getUTCSeconds()) + 'Z' : null;
179+
return isFinite(this.valueOf())
180+
? this.getUTCFullYear() + '-' +
181+
f(this.getUTCMonth() + 1) + '-' +
182+
f(this.getUTCDate()) + 'T' +
183+
f(this.getUTCHours()) + ':' +
184+
f(this.getUTCMinutes()) + ':' +
185+
f(this.getUTCSeconds()) + 'Z'
186+
: null;
186187
};
187188

188189
String.prototype.toJSON =
@@ -218,8 +219,9 @@ if (!JSON) {
218219
escapable.lastIndex = 0;
219220
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
220221
var c = meta[a];
221-
return typeof c === 'string' ? c :
222-
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
222+
return typeof c === 'string'
223+
? c
224+
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
223225
}) + '"' : '"' + string + '"';
224226
}
225227

@@ -303,9 +305,11 @@ if (!JSON) {
303305
// Join all of the elements together, separated with commas, and wrap them in
304306
// brackets.
305307

306-
v = partial.length === 0 ? '[]' : gap ?
307-
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
308-
'[' + partial.join(',') + ']';
308+
v = partial.length === 0
309+
? '[]'
310+
: gap
311+
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
312+
: '[' + partial.join(',') + ']';
309313
gap = mind;
310314
return v;
311315
}
@@ -340,9 +344,11 @@ if (!JSON) {
340344
// Join all of the member texts together, separated with commas,
341345
// and wrap them in braces.
342346

343-
v = partial.length === 0 ? '{}' : gap ?
344-
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
345-
'{' + partial.join(',') + '}';
347+
v = partial.length === 0
348+
? '{}'
349+
: gap
350+
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
351+
: '{' + partial.join(',') + '}';
346352
gap = mind;
347353
return v;
348354
}
@@ -468,8 +474,9 @@ if (!JSON) {
468474
// In the optional fourth stage, we recursively walk the new structure, passing
469475
// each name/value pair to a reviver function for possible transformation.
470476

471-
return typeof reviver === 'function' ?
472-
walk({'': j}, '') : j;
477+
return typeof reviver === 'function'
478+
? walk({'': j}, '')
479+
: j;
473480
}
474481

475482
// If the text is not JSON parseable, then a SyntaxError is thrown.

0 commit comments

Comments
 (0)