diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-27 14:25:47 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-27 15:02:34 -0700 |
commit | 6cf78084545fca66bac20a047e01312077e0ed7f (patch) | |
tree | 8e7430f12a567cd35628900f939f21ffaea0f456 /src/utility.js | |
parent | 2d45e5d75b9d7b475256415cc2c28225b89d6129 (diff) |
fast-path simple geps
Diffstat (limited to 'src/utility.js')
-rw-r--r-- | src/utility.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utility.js b/src/utility.js index 7d122cef..b793106c 100644 --- a/src/utility.js +++ b/src/utility.js @@ -334,6 +334,17 @@ function jsonCompare(x, y) { return JSON.stringify(x) == JSON.stringify(y); } +function sortedJsonCompare(x, y) { + if (x === null || typeof x !== 'object') return x === y; + for (var i in x) { + if (!sortedJsonCompare(x[i], y[i])) return false; + } + for (var i in y) { + if (!sortedJsonCompare(x[i], y[i])) return false; + } + return true; +} + function stringifyWithFunctions(obj) { if (typeof obj === 'function') return obj.toString(); if (obj === null || typeof obj !== 'object') return JSON.stringify(obj); |