New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior for .buffer
property of sliced Buffers
#6744
Comments
Buffer objects may come from a shared memory pool and the documentation mentions that in several places, grep for 'pool'. |
@bnoordhuis If there's a connection between any of the mentions of "pool" in the documentation, and the issue here, it's not clear to me. Are you implying that the behavior of the |
@jfirebaugh Yes: > Buffer.allocUnsafeSlow(16).slice(8).buffer.byteLength
16
> Buffer.allocUnsafe(16).slice(8).buffer.byteLength
8192 |
And for completeness, a third possibility:
Is this intended behavior for the |
Yes. It's worked that way since node v0.3 or v0.4, although the property was called |
Okay. Can you please document the |
Well, it's not, it's the same property. For example:
or
|
@vkurchatkin It does have different behavior, as I demonstrated in the initial description. For a
(I personally don't think 8192 is a defensible result here, but if you've decided that's the desired behavior, fine -- I'm just asking that it be documented.) |
Ok, disregard the above comment. After reading some more, I can see that the difference in behavior is stemming from |
closing then, |
Since instances of
Buffer
purport to also beUint8Array
TypedArray instances, I'd expect both of the following to produce8
:The fact that the
buffer
property on aBuffer
slice returns anArrayBuffer
viewing the entireBuffer
-- rather than just the slice as I expected -- looks like a bug to me. However, there's the possibility that this falls under the category of "subtle incompatibilities with the TypedArray specification" that the documentation mentions. If that is the case, please explicitly state that in the documentation.The text was updated successfully, but these errors were encountered: