NodeJS Buffer

Sun Nov 24, 2024

80 Words


NodeJS Buffer

I needed to work with binary files recently in JavaScript and for those of you that do not know JavaScript in the browser supports and ArrayBuffer object but it turns out since I was using NodeJS there is another option.

The NodeJS Buffer is used to represent a fixed array of bytes, and it turns out the File API allows me to read a binary file into a Buffer object which is pretty neat.

import fs from 'node:fs'