mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
buffer: expose underlying buffer object always
If the Buffer object's length is zero, or equal to the underlying buffer object's length, `parent` property returns `undefined`. > new Buffer(0).parent undefined > new Buffer(Buffer.poolSize).parent undefined This patch makes the buffer objects to consistently expose the buffer object via the `parent` property, always. Fixes: https://github.com/nodejs/node/issues/8266 PR-URL: https://github.com/nodejs/node/pull/8311 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e9b6fbbf17
commit
c21458a15d
4 changed files with 25 additions and 8 deletions
|
@ -13,9 +13,7 @@ const buf = Buffer.from(ab);
|
|||
|
||||
|
||||
assert.ok(buf instanceof Buffer);
|
||||
// For backwards compatibility of old .parent property test that if buf is not
|
||||
// a slice then .parent should be undefined.
|
||||
assert.equal(buf.parent, undefined);
|
||||
assert.equal(buf.parent, buf.buffer);
|
||||
assert.equal(buf.buffer, ab);
|
||||
assert.equal(buf.length, ab.byteLength);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue