Skip to content

Commit e108f20

Browse files
charmanderMylesBorins
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 b867294 commit e108f20

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
@@ -509,7 +509,7 @@ Buffer.prototype.equals = function equals(b) {
509509

510510

511511
// Override how buffers are presented by util.inspect().
512-
Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
512+
Buffer.prototype[internalUtil.customInspectSymbol] = function inspect() {
513513
var str = '';
514514
var max = exports.INSPECT_MAX_BYTES;
515515
if (this.length > 0) {
@@ -519,7 +519,7 @@ Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
519519
}
520520
return '<' + this.constructor.name + ' ' + str + '>';
521521
};
522-
Buffer.prototype.inspect = Buffer.prototype[internalUtil.inspectSymbol];
522+
Buffer.prototype.inspect = Buffer.prototype[internalUtil.customInspectSymbol];
523523

524524
Buffer.prototype.compare = function compare(target,
525525
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)