Hacker News new | past | comments | ask | show | jobs | submit login

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!




- 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)


Nit: "fixed-length" is no longer true as of very recently [1].

[1] https://github.com/tc39/proposal-resizablearraybuffer


Now it's bounded-length.


A File is a Blob, every file is `instanceof Blob`.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: