| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33f5345 commit e652781
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -989,7 +989,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 989 | 989 | keys = getKeys(value, ctx.showHidden); | |
| 990 | 990 | braces = ['{', '}']; | |
| 991 | 991 | if (typeof value === 'function') { | |
| 992 | - base = getFunctionBase(value, constructor, tag); | ||
| 992 | + base = getFunctionBase(ctx, value, constructor, tag); | ||
| 993 | 993 | if (keys.length === 0 && protoProps === undefined) | |
| 994 | 994 | return ctx.stylize(base, 'special'); | |
| 995 | 995 | } else if (constructor === 'Object') { | |
@@ -1223,7 +1223,7 @@ function getClassBase(value, constructor, tag) { | |||
| 1223 | 1223 | return `[${base}]`; | |
| 1224 | 1224 | } | |
| 1225 | 1225 | ||
| 1226 | - function getFunctionBase(value, constructor, tag) { | ||
| 1226 | + function getFunctionBase(ctx, value, constructor, tag) { | ||
| 1227 | 1227 | const stringified = FunctionPrototypeToString(value); | |
| 1228 | 1228 | if (StringPrototypeStartsWith(stringified, 'class') && stringified[stringified.length - 1] === '}') { | |
| 1229 | 1229 | const slice = StringPrototypeSlice(stringified, 5, -1); | |
@@ -1250,7 +1250,7 @@ function getFunctionBase(value, constructor, tag) { | |||
| 1250 | 1250 | if (value.name === '') { | |
| 1251 | 1251 | base += ' (anonymous)'; | |
| 1252 | 1252 | } else { | |
| 1253 | - base += `: ${value.name}`; | ||
| 1253 | + base += `: ${typeof value.name === 'string' ? value.name : formatValue(ctx, value.name)}`; | ||
| 1254 | 1254 | } | |
| 1255 | 1255 | base += ']'; | |
| 1256 | 1256 | if (constructor !== type && constructor !== null) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3394,3 +3394,13 @@ assert.strictEqual( | |||
| 3394 | 3394 | Object.defineProperty(BuiltinPrototype, 'constructor', desc); | |
| 3395 | 3395 | } | |
| 3396 | 3396 | } | |
| 3397 | + | ||
| 3398 | + { | ||
| 3399 | + function f() {} | ||
| 3400 | + Object.defineProperty(f, 'name', { value: Symbol('f') }); | ||
| 3401 | + | ||
| 3402 | + assert.strictEqual( | ||
| 3403 | + util.inspect(f), | ||
| 3404 | + '[Function: Symbol(f)]', | ||
| 3405 | + ); | ||
| 3406 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments