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 5260f53

Browse filesBrowse files
aduh95ruyadorno
authored andcommitted
lib: add support for inherited custom inspection methods
PR-URL: #48306 Fixes: #48207 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 27a4bc7 commit 5260f53
Copy full SHA for 5260f53

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎lib/internal/error_serdes.js‎

Copy file name to clipboardExpand all lines: lib/internal/error_serdes.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const {
1313
ObjectGetOwnPropertyNames,
1414
ObjectGetPrototypeOf,
1515
ObjectKeys,
16-
ObjectPrototypeHasOwnProperty,
1716
ObjectPrototypeToString,
1817
RangeError,
1918
ReferenceError,
@@ -134,8 +133,7 @@ function serializeError(error) {
134133
// Continue regardless of error.
135134
}
136135
try {
137-
if (error != null &&
138-
ObjectPrototypeHasOwnProperty(error, customInspectSymbol)) {
136+
if (error != null && customInspectSymbol in error) {
139137
return Buffer.from(StringFromCharCode(kCustomInspectedObject) + inspect(error), 'utf8');
140138
}
141139
} catch {
Collapse file

‎test/parallel/test-error-serdes.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-error-serdes.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,11 @@ const data = {
125125
}
126126
};
127127
assert.strictEqual(inspect(cycle(data)), 'barbaz');
128+
129+
const inheritedCustomInspect = new class {
130+
foo = 'bar';
131+
[inspect.custom]() {
132+
return 'barbaz';
133+
}
134+
}();
135+
assert.strictEqual(inspect(cycle(inheritedCustomInspect)), 'barbaz');

0 commit comments

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