From 68bfa91af702377bc4d0b36fc8ea25bcd16877a5 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 9 Mar 2014 16:46:54 -0400 Subject: [PATCH] buffer: allow toString to accept Infinity for end --- lib/buffer.js | 2 +- test/simple/test-buffer-inspect.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/buffer.js b/lib/buffer.js index d2d8b528c9..084d96f43a 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -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; diff --git a/test/simple/test-buffer-inspect.js b/test/simple/test-buffer-inspect.js index 7436fb861a..a13c69b4e0 100644 --- a/test/simple/test-buffer-inspect.js +++ b/test/simple/test-buffer-inspect.js @@ -49,3 +49,10 @@ expected = ''; 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