A file can exist on disk yet appear to be missing to a Node.js application. If its filename contains bytes that are not valid UTF-8, decoding those bytes into a string changes the name the application later passes back to the file system. Keeping the filename as raw bytes avoids that mistaken interpretation. section 2.1.4
A Node.js Buffer holds a sequence of zero or more bytes. It predates JavaScript Typed Arrays and is now a subclass of Uint8Array. Unlike a string, it can carry binary data without first assigning the bytes a text encoding; conversion to or from text is a separate step. section 2.1.2 section 2.1.4
Inspect a UTF-8 encoding
Buffer.from('⇇') produces <Buffer e2 87 87>. Those three bytes encode codepoint U+0021C7 in UTF-8; the Buffer lets you inspect the encoded bytes rather than the displayed character. section 2.1.2
Keep directory-entry names as bytes
Use readdirSync('./tmp', { encoding: 'buffer', withFileTypes: true }) when directory-entry names must remain uninterpreted bytes. The returned names can then be passed to file system APIs as Buffers instead of being decoded as strings first. section 2.1.4
Do not confuse a Buffer object with a stream’s internal buffer. A stream buffer is a place where chunks wait; its growth and backpressure are separate concerns from how a Buffer represents bytes. section 10.3.3 section 2.1.2
