4 ms·
> The Deno-specific APIs (like Deno.readTextFile()[0]) are Promise-based and have intuitive interfaces FYI, Node has Promise-based APIs for all filesystem APIs
by dfabulich 5y ago
> The Deno-specific APIs (like Deno.readTextFile()[0]) are Promise-based and have intuitive interfaces
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_options https://nodejs.org/api/fs.html#fs_filehandle_readfile_option...
- binarynate 5y agoThanks—I didn't know about fs/promises