From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 09:04:55 +0000 (-0800) Subject: Fix Buffer.inspect() output to match Node.js (test-buffer-prototype-inspect.js) X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=afd7e790a22e8f8a0f865b3c8baa68079a78185c;p=buffer.git Fix Buffer.inspect() output to match Node.js (test-buffer-prototype-inspect.js) --- 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 '' }