From f1f9aff8559cc63b81fdd49c8e43e91110380907 Mon Sep 17 00:00:00 2001 From: ghaiklor Date: Thu, 24 Mar 2016 20:45:43 +0200 Subject: [PATCH] doc: fix doc for Buffer.readInt32LE() Update example of readInt32LE method. buf.readInt32LE(1) is supposed to throw an error as it has only four elements and it tries to read 32 bits from three bytes. Fixes: https://github.com/nodejs/node/issues/5889 PR-URL: https://github.com/nodejs/node/pull/5890 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani --- doc/api/buffer.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 52b6956d0c019a..88891c68a42ac3 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -1054,8 +1054,10 @@ const buf = Buffer.from([1,-2,3,4]); buf.readInt32BE(); // returns 33424132 -buf.readInt32LE(1); +buf.readInt32LE(); // returns 67370497 +buf.readInt32LE(1); + // throws RangeError: Index out of range ``` ### buf.readIntBE(offset, byteLength[, noAssert])