Repository navigation
Replies: 1 comment
|
That overload describes binary reads, where the return value is a import { readFileSync } from 'node:fs';
const a: Buffer = readFileSync('sample.txt');
const b: Buffer = readFileSync('sample.txt', { encoding: null });
const c: Buffer = readFileSync('sample.txt', { encoding: undefined });
const d: string = readFileSync('sample.txt', { encoding: 'utf8' });
console.log(Buffer.isBuffer(a), Buffer.isBuffer(b), Buffer.isBuffer(c), typeof d);With a The Sources: Node's |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
For example, one of fs.readFileSync definition is
Why define the optional property
encodingas type ofnull | undefined?What could the use case of that ?
Thanks.
All reactions