Browse Source

buffer: use correct name for custom inspect symbol

59714cb7b3 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: https://github.com/nodejs/node/pull/9289
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Charmander 8 years ago
committed by James M Snell
parent
commit
66d54467c5
  1. 4
      lib/buffer.js
  2. 3
      test/parallel/test-buffer-inspect.js

4
lib/buffer.js

@ -527,7 +527,7 @@ Buffer.prototype.equals = function equals(b) {
// Override how buffers are presented by util.inspect(). // Override how buffers are presented by util.inspect().
Buffer.prototype[internalUtil.inspectSymbol] = function inspect() { Buffer.prototype[internalUtil.customInspectSymbol] = function inspect() {
var str = ''; var str = '';
var max = exports.INSPECT_MAX_BYTES; var max = exports.INSPECT_MAX_BYTES;
if (this.length > 0) { if (this.length > 0) {
@ -537,7 +537,7 @@ Buffer.prototype[internalUtil.inspectSymbol] = function inspect() {
} }
return '<' + this.constructor.name + ' ' + str + '>'; 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, Buffer.prototype.compare = function compare(target,
start, start,

3
test/parallel/test-buffer-inspect.js

@ -34,3 +34,6 @@ assert.doesNotThrow(function() {
assert.strictEqual(util.inspect(b), expected); assert.strictEqual(util.inspect(b), expected);
assert.strictEqual(util.inspect(s), expected); assert.strictEqual(util.inspect(s), expected);
}); });
b.inspect = undefined;
assert.strictEqual(util.inspect(b), expected);

Loading…
Cancel
Save