DEV Community

Discussion on: Writing a script to cross-post to DEV.to

Collapse
 
vonheikemen profile image
Heiker

There is something that you might find useful: the fs module has promise-based functions under the promises object.

So code like this is perfectly valid.

const { readFile } = require('fs').promises;

const somefunction = async () => { 
  const content = await readFile('file.txt', 'utf8');
   // moar code...
};
Enter fullscreen mode Exit fullscreen mode
Collapse
 
emma profile image
Emma Goto 🍙

Thanks for the tip!