Lightweight, dependency-free, promise wrapper around node.js' fs.
$ yarn add @haensl/pfs
# or npm
$ npm install -S @haensl/pfs
Exactly how you would use fs
. This is a drop-in replacement that converts any callback-based functions to promise-based ones.
const fs = require('@haensl/pfs')
// now uses promise
fs.readFile('my-file.txt', 'utf-8')
.then((content) => {
// do nice things
})
.catch(...)
// still works the same
fs.readFileSync('my-file.txt', 'utf-8')
// properties are also unchanged
fs.constants.R_OK
Based on Chris Deacy's pfs.