buffer: use a default offset

If none is provided, use zero as a default offset for all read/write
operations on the buffer.

PR-URL: https://github.com/nodejs/node/pull/19749
Refs: https://github.com/nodejs/node/pull/18395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Ruben Bridgewater authored and James M Snell committed 2018-04-16 16:11:12 -07:00
1 parent 1964978fb8
commit cdacafc8bb
8 files changed
+134 -70

No files matched your search

+6 -1
View File
@@ -62,7 +62,12 @@ assert.strictEqual(buffer.readFloatBE(0), 4.627507918739843e-41);
assert.strictEqual(buffer.readFloatLE(0), -Infinity);
['readFloatLE', 'readFloatBE'].forEach((fn) => {
['', '0', null, undefined, {}, [], () => {}, true, false].forEach((off) => {
// Verify that default offset works fine.
buffer[fn](undefined);
buffer[fn]();
['', '0', null, {}, [], () => {}, true, false].forEach((off) => {
assert.throws(
() => buffer[fn](off),
{ code: 'ERR_INVALID_ARG_TYPE' }