util: support AsyncGeneratorFunction in .inspect
This makes sure async generator functions are properly detected while using `util.inspect`. PR-URL: https://github.com/nodejs/node/pull/28056 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
be721e8db0
commit
a23c2308a7
@ -870,10 +870,11 @@ function getBoxedBase(value, ctx, keys, constructor, tag) {
|
||||
|
||||
function getFunctionBase(value, constructor, tag) {
|
||||
let type = 'Function';
|
||||
if (isGeneratorFunction(value)) {
|
||||
type = `Generator${type}`;
|
||||
}
|
||||
if (isAsyncFunction(value)) {
|
||||
type = 'AsyncFunction';
|
||||
} else if (isGeneratorFunction(value)) {
|
||||
type = 'GeneratorFunction';
|
||||
type = `Async${type}`;
|
||||
}
|
||||
let base = `[${type}`;
|
||||
if (constructor === null) {
|
||||
|
@ -48,6 +48,10 @@ assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction (anonymous)]');
|
||||
util.inspect(fn),
|
||||
'[GeneratorFunction (anonymous)]'
|
||||
);
|
||||
assert.strictEqual(
|
||||
util.inspect(async function* abc() {}),
|
||||
'[AsyncGeneratorFunction: abc]'
|
||||
);
|
||||
Object.setPrototypeOf(fn, Object.getPrototypeOf(async () => {}));
|
||||
assert.strictEqual(
|
||||
util.inspect(fn),
|
||||
|
Loading…
x
Reference in New Issue
Block a user