Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,14 @@ module.exports = class BufferList {
return ret;
}

[inspect.custom]() {
const obj = inspect({ length: this.length });
return `${this.constructor.name} ${obj}`;
// Make sure the linked list only shows the minimal necessary information.
[inspect.custom](_, options) {
return inspect(this, {
...options,
// Only inspect one level.
depth: 0,
// It should not recurse.
customInspect: false
});
}
};
11 changes: 11 additions & 0 deletions test/parallel/test-stream2-readable-from-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require('../common');
const assert = require('assert');
const fromList = require('_stream_readable')._fromList;
const BufferList = require('internal/streams/buffer_list');
const util = require('util');

function bufferListFromArray(arr) {
const bl = new BufferList();
Expand All @@ -41,6 +42,16 @@ function bufferListFromArray(arr) {
Buffer.from('kuel') ];
list = bufferListFromArray(list);

assert.strictEqual(
util.inspect([ list ], { compact: false }),
`[
BufferList {
head: [Object],
tail: [Object],
length: 4
}
]`);

// read more than the first element.
let ret = fromList(6, { buffer: list, length: 16 });
assert.strictEqual(ret.toString(), 'foogba');
Expand Down