Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f897860

Browse filesBrowse files
committed
util: support AsyncGeneratorFunction in .inspect
This makes sure async generator functions are properly detected while using `util.inspect`. PR-URL: #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>
1 parent b690e19 commit f897860
Copy full SHA for f897860

File tree

Expand file treeCollapse file tree

2 files changed

+8
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,11 @@ function getBoxedBase(value, ctx, keys, constructor, tag) {
847847

848848
function getFunctionBase(value, constructor, tag) {
849849
let type = 'Function';
850+
if (isGeneratorFunction(value)) {
851+
type = `Generator${type}`;
852+
}
850853
if (isAsyncFunction(value)) {
851-
type = 'AsyncFunction';
852-
} else if (isGeneratorFunction(value)) {
853-
type = 'GeneratorFunction';
854+
type = `Async${type}`;
854855
}
855856
let base = `[${type}`;
856857
if (constructor === null) {
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction]');
4848
util.inspect(fn),
4949
'[GeneratorFunction]'
5050
);
51+
assert.strictEqual(
52+
util.inspect(async function* abc() {}),
53+
'[AsyncGeneratorFunction: abc]'
54+
);
5155
Object.setPrototypeOf(fn, Object.getPrototypeOf(async () => {}));
5256
assert.strictEqual(
5357
util.inspect(fn),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.