mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
buffer: fix check for .buffer
property
isSharedArrayBuffer in fromObject was missing obj.buffer moved the 'length' in obj check so that it is checked first making the code slightly more performant and able to handle SharedArrayBuffer without relying on an explicit check. Ref: https://github.com/nodejs/node/pull/8510 PR-URL: https://github.com/nodejs/node/pull/8739 Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
647e8e5ae4
commit
2154bc89d8
2 changed files with 4 additions and 2 deletions
|
@ -27,3 +27,5 @@ assert.deepStrictEqual(arr_buf, ar_buf, 0);
|
|||
// Checks for calling Buffer.byteLength on a SharedArrayBuffer
|
||||
|
||||
assert.strictEqual(Buffer.byteLength(sab), sab.byteLength, 0);
|
||||
|
||||
assert.doesNotThrow(() => Buffer.from({buffer: sab}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue