Skip to content

Commit

Permalink
sort keys
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 5, 2014
1 parent 084f06a commit a07b19c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
return obj.inspect();
}
else if (typeof obj === 'object' && !isDate(obj) && !isRegExp(obj)) {
var xs = [];
var xs = [], keys = [];
for (var key in obj) {
if (!has(obj, key)) continue;
if (has(obj, key)) keys.push(key);
}
keys.sort();
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (/[^\w$]/.test(key)) {
xs.push(inspect(key) + ': ' + inspect(obj[key], obj));
}
Expand Down

0 comments on commit a07b19c

Please sign in to comment.