We have some data we're reading with code like:
const readData = fs.readFileSync('./dummy')
And readData
then looks like below, with a byteOffset
of 4664
We then need to make a buffer from that existing buffer by doing Buffer.from(readData)
to get a result with a byteOffset
of 0
for the data to be used in various applications, whether that's showing an image or decompressing some stored data from the file.
The question: I don't understand where this byteOffset
comes from in this scenario, what its purpose is, and why we need to re-buffer the buffer data to get a usable output from fs.readFileSync
.
I've read through the docs but it hasn't helped to answer any of my questions.