GeezerVison is showing github.com — util: fix inspect indentation of detached DataView · nodejs/node@5d68405
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2545,8 +2545,11 @@ function formatPromise(ctx, value, recurseTimes) { |
2545 | 2545 | } |
2546 | 2546 |
|
2547 | 2547 | function formatExtraProperties(ctx, value, recurseTimes, key, typedArray) { |
| 2548 | + // Read the value before indenting: the getter throws for a detached |
| 2549 | + // DataView, and formatRaw() then retries with a fallback value. |
| 2550 | + const extraValue = value[key]; |
2548 | 2551 | ctx.indentationLvl += 2; |
2549 | | - const str = formatValue(ctx, value[key], recurseTimes, typedArray); |
| 2552 | + const str = formatValue(ctx, extraValue, recurseTimes, typedArray); |
2550 | 2553 | ctx.indentationLvl -= 2; |
2551 | 2554 |
|
2552 | 2555 | // These entries are mainly getters. Should they be formatted like getters? |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -217,10 +217,10 @@ assert.doesNotMatch( |
217 | 217 | assert.strictEqual( |
218 | 218 | util.inspect(dv), |
219 | 219 | 'DataView {\n' + |
220 | | - ' [byteLength]: 0,\n' + |
221 | | - ' [byteOffset]: undefined,\n' + |
222 | | - ' [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' + |
223 | | - ' }', |
| 220 | + ' [byteLength]: 0,\n' + |
| 221 | + ' [byteOffset]: undefined,\n' + |
| 222 | + ' [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' + |
| 223 | + '}', |
224 | 224 | ); |
225 | 225 | } |
226 | 226 |
|
|