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: nodejs#9289
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
charmander authored and addaleax committed Nov 18, 2016
1 parent f17e7d2 commit 974f984
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 @@ -470,7 +470,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 @@ -480,7 +480,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(b) {
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 @@ -36,3 +36,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 974f984

Please sign in to comment.