mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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:
1 parent
1964978fb8
commit
cdacafc8bb
8 files changed
+134
-70
No files matched your search
@@ -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' }
|
||||
|
||||
Reference in new issue
Block a user