Replies: 0 comments 2 replies
-
| Depends on what you're doing. Uint8Array is fine for simple byte manipulations but you probably can't beat buffer.includes() with your lovingly open-coded version except for trivial searches. | 
Beta Was this translation helpful? Give feedback.
-
| In Node.js, the choice between Buffer and TypedArrays depends on your needs. Buffer has a bigger API and was re-implemented for compatibility and performance. Performance may vary, so benchmark your specific use case. If you want a larger API and are comfortable with potential quirks, go with Buffer. If you prefer a standardized and predictable API, use TypedArrays like Uint8Array, following Node.js documentation recommendations. | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
However, after typed arrays were introduced with ES6 (in 2015) standard, the Node.js
Bufferwas re-implemented to extend fromUint8Arrayfor better compatibility and performance. This madeBuffera kind of typed array.Several online sources, including StackOverflow answers, mention that
Bufferhas a bigger API and better performance, compared to ES6TypedArrays.It's obvious that
Bufferhas a larger API, whereBufferseems to have approximately 62 methods , whileTypedArrayhave only approximately 34 .However, I'm unable to find anything trustworthy regarding performance? Previous documentation version mentioned that
Buffer.slicesis more efficient thanTypedArray.slices, but that statement has since been removed in recent versions.Furthermore, the Node.JS docs recommend using
TypedArray's likeUint8Arraywith.slices()since theBuffer's implementation can have unexpected behaviour.So, is
Buffermainly a good choice because of it's larger API, or, are there still some performance related features around it?Beta Was this translation helpful? Give feedback.
All reactions