projects
/
buffer.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e104540
)
Fix Buffer.inspect() output to match Node.js (test-buffer-prototype-inspect.js)
author
Feross Aboukhadijeh
<feross@feross.org>
Fri, 16 Feb 2018 09:04:55 +0000
(
01:04
-0800)
committer
Feross Aboukhadijeh
<feross@feross.org>
Fri, 16 Feb 2018 09:04:55 +0000
(
01:04
-0800)
index.js
patch
|
blob
|
history
diff --git
a/index.js
b/index.js
index 4acc3d1e50bb12aacc7e710b9c3b87382f976fda..0327f29d0c7385dbd39faff7ac4f68e6aa3749e4 100644
(file)
--- 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 '<Buffer ' + str + '>'
}