Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

deepEquals key sorting is now recursive, all tests pass

  • Loading branch information...
commit b90ef377f83fd3dced57998b509c0599a21c184b 1 parent d3c4486
@substack authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/tap-assert.js
View
12 lib/tap-assert.js
@@ -315,18 +315,18 @@ function selectFields (a, b) {
}
function sortObject (obj) {
+ if (typeof obj !== 'object' || Array.isArray(obj) || obj === null) {
+ return obj
+ }
+
return Object.keys(obj).sort().reduce(function (acc, key) {
- acc[key] = obj[key]
+ acc[key] = sortObject(obj[key])
return acc
}, {})
}
function stringify (a) {
- if (typeof a === 'object' && !Array.isArray(a) && a !== null) {
- a = sortObject(a)
- }
-
- return JSON.stringify(a, (function () {
+ return JSON.stringify(sortObject(a), (function () {
var seen = []
, keys = []
return function (key, val) {
Please sign in to comment.
Something went wrong with that request. Please try again.