Skip to content

Commit 4e576e5

Browse files
committed
[Refactor] consolidate Map/Set notations.
1 parent 4e440cd commit 4e576e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
9393
mapForEach.call(obj, function (value, key) {
9494
parts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
9595
});
96-
return 'Map (' + mapSize.call(obj) + ') {' + parts.join(', ') + '}';
96+
return collectionOf('Map', mapSize.call(obj), parts);
9797
}
9898
if (isSet(obj)) {
9999
var parts = [];
100100
setForEach.call(obj, function (value ) {
101101
parts.push(inspect(value, obj));
102102
});
103-
return 'Set (' + setSize.call(obj) + ') {' + parts.join(', ') + '}';
103+
return collectionOf('Set', setSize.call(obj), parts);
104104
}
105105
if (typeof obj !== 'object') {
106106
return String(obj);
@@ -216,3 +216,7 @@ function inspectString (str) {
216216
function markBoxed (str) {
217217
return 'Object(' + str + ')';
218218
}
219+
220+
function collectionOf(type, size, entries) {
221+
return type + ' (' + size + ') {' + entries.join(', ') + '}';
222+
}

0 commit comments

Comments
 (0)