by dfabulich · 5y ago · 0 comments
FYI, Node has Promise-based APIs for all filesystem APIs. Node also supports ES modules that use top-level await.
If you create a file `test.mjs` and put this in it, it'll work:
import {readFile} from 'fs/promises';
console.log(await readFile('foo.txt', 'utf8'));
https://nodejs.org/api/fs.html#fs_filehandle_readfile_option...