mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -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
@@ -61,6 +61,11 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
|
||||
const small = Buffer.allocUnsafe(1);
|
||||
|
||||
['writeFloatLE', 'writeFloatBE'].forEach((fn) => {
|
||||
|
||||
// Verify that default offset works fine.
|
||||
buffer[fn](23, undefined);
|
||||
buffer[fn](23);
|
||||
|
||||
assert.throws(
|
||||
() => small[fn](11.11, 0),
|
||||
{
|
||||
@@ -69,7 +74,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
|
||||
message: 'Attempt to write outside buffer bounds'
|
||||
});
|
||||
|
||||
['', '0', null, undefined, {}, [], () => {}, true, false].forEach((off) => {
|
||||
['', '0', null, {}, [], () => {}, true, false].forEach((off) => {
|
||||
assert.throws(
|
||||
() => small[fn](23, off),
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' }
|
||||
|
||||
Reference in new issue
Block a user