Skip to content

Commit 212da12

Browse files
charmanderevanlucas
authored andcommitted
buffer: use correct name for custom inspect symbol
59714cb introduced the `util.inspect.custom` symbol, but it was exported as `customInspectSymbol` by `internal/util.js` and referenced as `inspectSymbol` by `buffer.js`. PR-URL: #9289 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0ab008e commit 212da12

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/buffer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ Buffer.prototype.equals = function equals(b) {
527527

528528

529529
// Override how buffers are presented by util.inspect().
530-
Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
530+
Buffer.prototype[internalUtil.customInspectSymbol] = function inspect() {
531531
var str = '';
532532
var max = exports.INSPECT_MAX_BYTES;
533533
if (this.length > 0) {
@@ -537,7 +537,7 @@ Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
537537
}
538538
return '<' + this.constructor.name + ' ' + str + '>';
539539
};
540-
Buffer.prototype.inspect = Buffer.prototype[internalUtil.inspectSymbol];
540+
Buffer.prototype.inspect = Buffer.prototype[internalUtil.customInspectSymbol];
541541

542542
Buffer.prototype.compare = function compare(target,
543543
start,

test/parallel/test-buffer-inspect.js

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ assert.doesNotThrow(function() {
3434
assert.strictEqual(util.inspect(b), expected);
3535
assert.strictEqual(util.inspect(s), expected);
3636
});
37+
38+
b.inspect = undefined;
39+
assert.strictEqual(util.inspect(b), expected);

0 commit comments

Comments
 (0)