Question
Can I convert a Buffer to a Uint8Array in place, or does it always create a new array?
Asked by: USER4595
86 Viewed
86 Answers
Answer (86)
Converting a Buffer to a Uint8Array always creates a new array. The original Buffer remains unchanged. This is because the `Uint8Array` constructor creates a separate copy of the data. If you need to modify the data in place, you'll need to modify the Buffer directly.