judge 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  http://www.JSON.org/json2.js
3
- 2010-08-25
3
+ 2011-10-19
4
4
 
5
5
  Public Domain.
6
6
 
@@ -146,7 +146,7 @@
146
146
  redistribute.
147
147
  */
148
148
 
149
- /*jslint evil: true, strict: false */
149
+ /*jslint evil: true, regexp: true */
150
150
 
151
151
  /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152
152
  call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
@@ -159,11 +159,13 @@
159
159
  // Create a JSON object only if one does not already exist. We create the
160
160
  // methods in a closure to avoid creating global variables.
161
161
 
162
- if (!this.JSON) {
163
- this.JSON = {};
162
+ var JSON;
163
+ if (!JSON) {
164
+ JSON = {};
164
165
  }
165
166
 
166
167
  (function () {
168
+ 'use strict';
167
169
 
168
170
  function f(n) {
169
171
  // Format integers to have at least two digits.
@@ -174,20 +176,21 @@ if (!this.JSON) {
174
176
 
175
177
  Date.prototype.toJSON = function (key) {
176
178
 
177
- return isFinite(this.valueOf()) ?
178
- this.getUTCFullYear() + '-' +
179
- f(this.getUTCMonth() + 1) + '-' +
180
- f(this.getUTCDate()) + 'T' +
181
- f(this.getUTCHours()) + ':' +
182
- f(this.getUTCMinutes()) + ':' +
183
- 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;
184
187
  };
185
188
 
186
- String.prototype.toJSON =
187
- Number.prototype.toJSON =
188
- Boolean.prototype.toJSON = function (key) {
189
- return this.valueOf();
190
- };
189
+ String.prototype.toJSON =
190
+ Number.prototype.toJSON =
191
+ Boolean.prototype.toJSON = function (key) {
192
+ return this.valueOf();
193
+ };
191
194
  }
192
195
 
193
196
  var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -214,13 +217,12 @@ if (!this.JSON) {
214
217
  // sequences.
215
218
 
216
219
  escapable.lastIndex = 0;
217
- return escapable.test(string) ?
218
- '"' + string.replace(escapable, function (a) {
219
- var c = meta[a];
220
- return typeof c === 'string' ? c :
221
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
222
- }) + '"' :
223
- '"' + string + '"';
220
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
221
+ var c = meta[a];
222
+ return typeof c === 'string'
223
+ ? c
224
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
225
+ }) + '"' : '"' + string + '"';
224
226
  }
225
227
 
226
228
 
@@ -303,11 +305,11 @@ if (!this.JSON) {
303
305
  // Join all of the elements together, separated with commas, and wrap them in
304
306
  // brackets.
305
307
 
306
- v = partial.length === 0 ? '[]' :
307
- gap ? '[\n' + gap +
308
- partial.join(',\n' + gap) + '\n' +
309
- mind + ']' :
310
- '[' + partial.join(',') + ']';
308
+ v = partial.length === 0
309
+ ? '[]'
310
+ : gap
311
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
312
+ : '[' + partial.join(',') + ']';
311
313
  gap = mind;
312
314
  return v;
313
315
  }
@@ -317,8 +319,8 @@ if (!this.JSON) {
317
319
  if (rep && typeof rep === 'object') {
318
320
  length = rep.length;
319
321
  for (i = 0; i < length; i += 1) {
320
- k = rep[i];
321
- if (typeof k === 'string') {
322
+ if (typeof rep[i] === 'string') {
323
+ k = rep[i];
322
324
  v = str(k, value);
323
325
  if (v) {
324
326
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -330,7 +332,7 @@ if (!this.JSON) {
330
332
  // Otherwise, iterate through all of the keys in the object.
331
333
 
332
334
  for (k in value) {
333
- if (Object.hasOwnProperty.call(value, k)) {
335
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
334
336
  v = str(k, value);
335
337
  if (v) {
336
338
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -342,9 +344,11 @@ if (!this.JSON) {
342
344
  // Join all of the member texts together, separated with commas,
343
345
  // and wrap them in braces.
344
346
 
345
- v = partial.length === 0 ? '{}' :
346
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
347
- mind + '}' : '{' + partial.join(',') + '}';
347
+ v = partial.length === 0
348
+ ? '{}'
349
+ : gap
350
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
351
+ : '{' + partial.join(',') + '}';
348
352
  gap = mind;
349
353
  return v;
350
354
  }
@@ -385,7 +389,7 @@ if (!this.JSON) {
385
389
  rep = replacer;
386
390
  if (replacer && typeof replacer !== 'function' &&
387
391
  (typeof replacer !== 'object' ||
388
- typeof replacer.length !== 'number')) {
392
+ typeof replacer.length !== 'number')) {
389
393
  throw new Error('JSON.stringify');
390
394
  }
391
395
 
@@ -415,7 +419,7 @@ if (!this.JSON) {
415
419
  var k, v, value = holder[key];
416
420
  if (value && typeof value === 'object') {
417
421
  for (k in value) {
418
- if (Object.hasOwnProperty.call(value, k)) {
422
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
419
423
  v = walk(value, k);
420
424
  if (v !== undefined) {
421
425
  value[k] = v;
@@ -456,9 +460,9 @@ if (!this.JSON) {
456
460
  // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
457
461
 
458
462
  if (/^[\],:{}\s]*$/
459
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
460
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
461
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
463
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
464
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
465
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
462
466
 
463
467
  // In the third stage we use the eval function to compile the text into a
464
468
  // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
@@ -470,8 +474,9 @@ if (!this.JSON) {
470
474
  // In the optional fourth stage, we recursively walk the new structure, passing
471
475
  // each name/value pair to a reviver function for possible transformation.
472
476
 
473
- return typeof reviver === 'function' ?
474
- walk({'': j}, '') : j;
477
+ return typeof reviver === 'function'
478
+ ? walk({'': j}, '')
479
+ : j;
475
480
  }
476
481
 
477
482
  // If the text is not JSON parseable, then a SyntaxError is thrown.