node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »

readdirfiles

readdirfiles

Node.js' fs.readdir + fs.readFile.

Usage

$ mkdir numbers
$ echo "one" > numbers/1
$ echo "two" > numbers/2
$ echo "three" > numbers/3
$ npm install readdirfiles
(...)
$ node
> let readdirFiles = require('readdirfiles')
undefined
> readdirFiles('numbers', 'utf8', function (err, files) { console.dir(files) })
undefined
> [ { path: 'numbers/1', content: 'one\n' },
  { path: 'numbers/2', content: 'two\n' },
  { path: 'numbers/3', content: 'three\n' } ]
> /*
... There's a ReadableStream too if you want:
... var rs = new readdirFiles.Stream('numbers', 'utf8')
... */
undefined