-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Buffer.from Offset #7134
Comments
/cc @nodejs/buffer |
Documentation is a bit confusing. Passing What you're likely expecting is msgAnswer = Buffer.from(msgReceivingBuffer.buffer,
msgReceivingBuffer.byteOffset + msgSentBuffer.length); Can you try that out and let me know if it works for you? Side note, reason the API is setup like this is because if a dev simply wants to slice the buffer then they can run |
Thanks, your solution nearly worked. Without the third
Just to understand, why is
So every single Buffer object is just allocated space in that global Buffer object? |
In certain cases we optimize new Buffer allocations by using a preallocated larger Buffer and take a slice from that. It's just a performance optimization for certain cases. |
Offset is not applied in
Buffer.from
Or is
The optional byteOffset and length arguments specify a memory range within the arrayBuffer that will be shared by the Buffer.
this to be understood as:The text was updated successfully, but these errors were encountered: