[Pkg-javascript-commits] [json-js] 60/85: no mess
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 ff55d8d4513b149e2511aee01c3a61d372837d1f
Author: Douglas Crockford <douglascrockford at github.com>
Date: Wed Feb 20 03:42:34 2013 -0800
no mess
---
cycle.js | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/cycle.js b/cycle.js
index 7187bf4..5312e38 100644
--- a/cycle.js
+++ b/cycle.js
@@ -1,6 +1,6 @@
/*
cycle.js
- 2012-08-19
+ 2013-02-19
Public Domain.
@@ -50,20 +50,15 @@ if (typeof JSON.decycle !== 'function') {
name, // Property name
nu; // The new object or array
- switch (typeof value) {
- case 'object':
+// typeof null === 'object', so go on if this value is really an object but not
+// one of the weird builtin objects.
-// typeof null === 'object', so get out if this value is not really an object.
-// Also get out if it is a weird builtin object.
-
- if (value === null ||
- value instanceof Boolean ||
- value instanceof Date ||
- value instanceof Number ||
- value instanceof RegExp ||
- value instanceof String) {
- return value;
- }
+ if (typeof value === 'object' && value !== null &&
+ !(value instanceof Boolean) &&
+ !(value instanceof Date) &&
+ !(value instanceof Number) &&
+ !(value instanceof RegExp) &&
+ !(value instanceof String)) {
// If the value is an object or array, look to see if we have already
// encountered it. If so, return a $ref/path object. This is a hard way,
@@ -100,11 +95,8 @@ if (typeof JSON.decycle !== 'function') {
}
}
return nu;
- case 'number':
- case 'string':
- case 'boolean':
- return value;
}
+ return value;
}(object, '$'));
};
}
--
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