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:
Ruben Bridgewater committed 2019-06-17 21:12:09 +02:00
1 parent b690e19a9a
commit f897860427
2 files changed
+8 -3

No files matched your search

+4 -3
View File
@@ -847,10 +847,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) {
+4
View File
@@ -48,6 +48,10 @@ assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction]');
util.inspect(fn),
'[GeneratorFunction]'
);
assert.strictEqual(
util.inspect(async function* abc() {}),
'[AsyncGeneratorFunction: abc]'
);
Object.setPrototypeOf(fn, Object.getPrototypeOf(async () => {}));
assert.strictEqual(
util.inspect(fn),