Uint8Array is a general-purpose byte-array that’s available in both nodejs and browsers. Buffer is a subclass of Uint8Array that’s only available in Node.js (for historical reasons). both are primarily used for manipulating binary (byte) data.
historically, when Node.js first came about, general-purpose Uint8Arrays didn’t exist, so it had to invent its own “Buffer” type for handling binary-data. after general-purpose Uint8Arrays were introduced with ES6, Node.js (after version 4.0) decided to migrate Buffer over from a separate data-type -> subclass of Uint8Array (to try and make it more browser-compatible with Uint8Array).
https://www.quora.com/What-is-the-relationship-between-a-Buffer-and-an-Uint8Array-in-Node-js
Answer from Orkhan Huseynli on Stack Overflowbody size difference using uint8array vs buffer for post request
What is the difference between an array and an ArrayBuffer?
No differentiation between `ArrayBuffer` and `Uint8Array`
Start moving to Uint8Array in new APIs?
I’m always ending up guessing.. I need to somehow understand. I have no idea what I’m doing when working with files. Just trying stuff until it works. Someone plz ELI5..
My current issue is getting a png file from Firebase storage which gives a “file” which I’m trying to add on a pdf, where the library expects a Uint8Array or Arraybuffer. I’ve been doing similar things before. But end up just guessing my way until it works, and this time.. well it doesn’t work. I guessed it all with no success. I don’t know what I’m doing so I guess I need to actually learn ;)