4 ms·
I had to deal with binary data in a project recently and all the options made my head spin. File, Blob, Buffer, ArrayBuffer, Uint8Array, and so on. Was very co
by vendiddy 3y ago
I had to deal with binary data in a project recently and all the options made my head spin. File, Blob, Buffer, ArrayBuffer, Uint8Array, and so on.
Was very confused on what to use!
- mofle 3y ago- Blob: Immutable raw data container with a size and MIME type, not directly readable. - File: Like a Blob, but with additional file-specific properties (e.g., filename). - ArrayBuffer: Fixed-length raw binary data in JavaScript, not directly accessible. - Uint8Array: Interface for reading/writing binary data in ArrayBuffer, showing them as 8-bit unsigned integers. - Buffer: Readable/writable raw binary data container in Node.js (subclass of Uint8Array)
- bakkoting 3y agoNit: "fixed-length" is no longer true as of very recently [1]. [1] https://github.com/tc39/proposal-resizablearraybuffer https://github.com/tc39/proposal-resizablearraybuffer
- pwdisswordfishc 3y agoNow it's bounded-length.
- explaininjs 3y agoA File is a Blob, every file is `instanceof Blob`.