GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: improve buffer list inspection · nodejs/node@25bf1f5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams
    • buffer_list.js
  • test/parallel
    • test-stream2-readable-from-list.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/buffer_list.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/buffer_list.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ module.exports = class BufferList {
158158
return ret;
159159
}
160160

161-
[inspect.custom]() {
162-
const obj = inspect({ length: this.length });
163-
return `${this.constructor.name} ${obj}`;
161+
// Make sure the linked list only shows the minimal necessary information.
162+
[inspect.custom](_, options) {
163+
return inspect(this, {
164+
...options,
165+
// Only inspect one level.
166+
depth: 0,
167+
// It should not recurse.
168+
customInspect: false
169+
});
164170
}
165171
};
Collapse file

‎test/parallel/test-stream2-readable-from-list.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream2-readable-from-list.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require('../common');
2525
const assert = require('assert');
2626
const fromList = require('_stream_readable')._fromList;
2727
const BufferList = require('internal/streams/buffer_list');
28+
const util = require('util');
2829

2930
function bufferListFromArray(arr) {
3031
const bl = new BufferList();
@@ -41,6 +42,16 @@ function bufferListFromArray(arr) {
4142
Buffer.from('kuel') ];
4243
list = bufferListFromArray(list);
4344

45+
assert.strictEqual(
46+
util.inspect([ list ], { compact: false }),
47+
`[
48+
BufferList {
49+
head: [Object],
50+
tail: [Object],
51+
length: 4
52+
}
53+
]`);
54+
4455
// read more than the first element.
4556
let ret = fromList(6, { buffer: list, length: 16 });
4657
assert.strictEqual(ret.toString(), 'foogba');

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.