From afd7e790a22e8f8a0f865b3c8baa68079a78185c Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 01:04:55 -0800 Subject: [PATCH] Fix Buffer.inspect() output to match Node.js (test-buffer-prototype-inspect.js) --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4acc3d1..0327f29 100644 --- a/index.js +++ b/index.js @@ -600,10 +600,8 @@ Buffer.prototype.equals = function equals (b) { Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' return '' } -- 2.34.1