Skip to content

Commit fd38e1b

Browse files
committed
[New] add enumerable properties to Function inspect result, per node’s assert
1 parent 01ac3e4 commit fd38e1b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ module.exports = function inspect_(obj, options, depth, seen) {
106106

107107
if (typeof obj === 'function') {
108108
var name = nameOf(obj);
109-
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']';
109+
var keys = arrObjKeys(obj, inspect);
110+
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + keys.join(', ') + ' }' : '');
110111
}
111112
if (isSymbol(obj)) {
112113
var symString = symToString.call(obj);

test/fn.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ test('function name', function (t) {
1212
var f = (function () {
1313
return function () {};
1414
}());
15-
f.toString = function () { return 'function xxx () {}'; };
15+
f.toString = function toStr() { return 'function xxx () {}'; };
1616
var obj = [1, 2, f, 4];
17-
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
17+
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)] { toString: [Function: toStr] }, 4 ]');
1818
});
1919

2020
test('anon function', function (t) {

0 commit comments

Comments
 (0)