buffer: allow toString to accept Infinity for end
authorBrian White <mscdex@mscdex.net>
Sun, 9 Mar 2014 20:46:54 +0000 (16:46 -0400)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Mon, 10 Mar 2014 20:20:28 +0000 (13:20 -0700)
lib/buffer.js
test/simple/test-buffer-inspect.js

index d2d8b52..084d96f 100644 (file)
@@ -208,7 +208,7 @@ Buffer.prototype.toString = function(encoding, start, end) {
   var loweredCase = false;
 
   start = start >>> 0;
-  end = util.isUndefined(end) ? this.length : end >>> 0;
+  end = util.isUndefined(end) || end === Infinity ? this.length : end >>> 0;
 
   if (!encoding) encoding = 'utf8';
   if (start < 0) start = 0;
index 7436fb8..a13c69b 100644 (file)
@@ -49,3 +49,10 @@ expected = '<Buffer 31 32>';
 
 assert.strictEqual(util.inspect(b), expected);
 assert.strictEqual(util.inspect(s), expected);
+
+buffer.INSPECT_MAX_BYTES = Infinity;
+
+assert.doesNotThrow(function() {
+  assert.strictEqual(util.inspect(b), expected);
+  assert.strictEqual(util.inspect(s), expected);
+});
\ No newline at end of file