Skip to content

Commit aca6265

Browse files
committed
[Refactor] move object key gathering into separate function
1 parent 6f2c11e commit aca6265

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
116116
}
117117
if (!isDate(obj) && !isRegExp(obj)) {
118118
var xs = [];
119-
var keys = [];
120-
for (var key in obj) {
121-
if (has(obj, key)) keys.push(key);
122-
}
119+
var keys = objectKeys(obj);
123120
keys.sort();
124121
for (var i = 0; i < keys.length; i++) {
125122
var key = keys[i];
@@ -134,6 +131,14 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
134131
return String(obj);
135132
};
136133

134+
function objectKeys(obj) {
135+
var keys = [];
136+
for (var key in obj) {
137+
if (has(obj, key)) keys.push(key);
138+
}
139+
return keys;
140+
}
141+
137142
function quote (s) {
138143
return String(s).replace(/"/g, '&quot;');
139144
}

0 commit comments

Comments
 (0)