Skip to content

Commit

Permalink
buffer: use correct name for custom inspect symbol
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
charmander authored and evanlucas committed Nov 3, 2016
1 parent 0ab008e commit 212da12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ Buffer.prototype.equals = function equals(b) {


// Override how buffers are presented by util.inspect().
Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
Buffer.prototype[internalUtil.customInspectSymbol] = function inspect() {
var str = '';
var max = exports.INSPECT_MAX_BYTES;
if (this.length > 0) {
Expand All @@ -537,7 +537,7 @@ Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
}
return '<' + this.constructor.name + ' ' + str + '>';
};
Buffer.prototype.inspect = Buffer.prototype[internalUtil.inspectSymbol];
Buffer.prototype.inspect = Buffer.prototype[internalUtil.customInspectSymbol];

Buffer.prototype.compare = function compare(target,
start,
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-buffer-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ assert.doesNotThrow(function() {
assert.strictEqual(util.inspect(b), expected);
assert.strictEqual(util.inspect(s), expected);
});

b.inspect = undefined;
assert.strictEqual(util.inspect(b), expected);

0 comments on commit 212da12

Please sign in to comment.