[Pkg-javascript-commits] [json-js] 62/85: hygiene
Jonas Smedegaard
dr at jones.dk
Mon Mar 14 10:39:42 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository json-js.
commit e39db4b7e6249f04a195e7dd0840e610cc9e941e
Author: Douglas Crockford <douglascrockford at github.com>
Date: Sun May 26 07:58:04 2013 -0700
hygiene
---
json.js | 42 ++++++++++++++++++++++++------------------
json2.js | 6 +++---
json_parse_state.js | 4 ++--
3 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/json.js b/json.js
index 9a338bf..f673229 100644
--- a/json.js
+++ b/json.js
@@ -1,6 +1,6 @@
/*
json.js
- 2012-10-08
+ 2013-05-26
Public Domain
@@ -212,13 +212,14 @@ if (typeof JSON !== 'object') {
Date.prototype.toJSON = function (key) {
- return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
+ return isFinite(this.valueOf())
+ ? this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z'
+ : null;
};
String.prototype.toJSON =
@@ -254,8 +255,9 @@ if (typeof JSON !== 'object') {
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ return typeof c === 'string'
+ ? c
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
@@ -339,9 +341,11 @@ if (typeof JSON !== 'object') {
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
- v = partial.length === 0 ? '[]' : gap ?
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
- '[' + partial.join(',') + ']';
+ v = partial.length === 0
+ ? '[]'
+ : gap
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+ : '[' + partial.join(',') + ']';
gap = mind;
return v;
}
@@ -376,9 +380,10 @@ if (typeof JSON !== 'object') {
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
- v = partial.length === 0 ? '{}' : gap ?
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
- '{' + partial.join(',') + '}';
+ v = partial.length === 0 ? '{}'
+ : gap
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+ : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
@@ -504,8 +509,9 @@ if (typeof JSON !== 'object') {
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
- return typeof reviver === 'function' ?
- walk({'': j}, '') : j;
+ return typeof reviver === 'function'
+ ? walk({'': j}, '')
+ : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
diff --git a/json2.js b/json2.js
index c7745df..d89ecc7 100644
--- a/json2.js
+++ b/json2.js
@@ -1,6 +1,6 @@
/*
json2.js
- 2012-10-08
+ 2013-05-26
Public Domain.
@@ -173,7 +173,7 @@ if (typeof JSON !== 'object') {
if (typeof Date.prototype.toJSON !== 'function') {
- Date.prototype.toJSON = function (key) {
+ Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
@@ -187,7 +187,7 @@ if (typeof JSON !== 'object') {
String.prototype.toJSON =
Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
+ Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
diff --git a/json_parse_state.js b/json_parse_state.js
index 142229f..7424fcc 100644
--- a/json_parse_state.js
+++ b/json_parse_state.js
@@ -1,6 +1,6 @@
/*
json_parse_state.js
- 2012-06-01
+ 2013-05-26
Public Domain.
@@ -46,7 +46,7 @@
NOT CONTROL.
*/
-/*jslint regexp: false*/
+/*jslint regexp: true, unparam: true */
/*members "", "\"", ",", "\/", ":", "[", "\\", "]", acomma, avalue, b,
call, colon, container, exec, f, false, firstavalue, firstokey,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/json-js.git
More information about the Pkg-javascript-commits
mailing list