Browse Source

buffer: fix inspect throw if slice length too long

All the Buffer#{ascii,hex,etc.}Slice() methods are intentionally strict
to alert if a Buffer instance was attempting to be accessed out of
bounds. Buffer#toString() is the more user friendly way of accessing the
data, and will coerce values to their min/max on overflow.
v0.11.7-release
Trevor Norris 12 years ago
parent
commit
fa89cf545c
  1. 2
      lib/buffer.js

2
lib/buffer.js

@ -239,7 +239,7 @@ Buffer.prototype.inspect = function inspect() {
var str = '';
var max = exports.INSPECT_MAX_BYTES;
if (this.length > 0) {
str = this.hexSlice(0, max).match(/.{2}/g).join(' ');
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
if (this.length > max)
str += ' ... ';
}

Loading…
Cancel
Save