From e108f20d5c4bb23b71c8ed0e051b537b8a349b0f Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Tue, 25 Oct 2016 22:27:14 -0700 Subject: [PATCH] buffer: use correct name for custom inspect symbol 59714cb7b3918c9e4fcd94013b778078d3710705 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 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/buffer.js | 4 ++-- test/parallel/test-buffer-inspect.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 3e745cde797aac..9ebeb66a268981 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -509,7 +509,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) { @@ -519,7 +519,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, diff --git a/test/parallel/test-buffer-inspect.js b/test/parallel/test-buffer-inspect.js index 4239d787ea10ba..4fed249207611b 100644 --- a/test/parallel/test-buffer-inspect.js +++ b/test/parallel/test-buffer-inspect.js @@ -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);