activerules-read-files
A Node module to read multiple files asynchronously. MISSING FILES WILL BE IGNORED without error.
const multipleFiles = ; ;
Installation
npm install activerules-read-files
API
const multipleFiles = ;
multipleFiles(paths [, options], callback)
paths: Array
of String
(file paths)
options: Object
(fs.readFile options) or String
(encoding)
callback: Function
callback(error, contents)
error: Error
if it fails terribly, otherwise null
, it does not error on a missing file.
contents: Array
of Buffer
or String
(according to encoding
option)
The second argument will be an array of file contents. The order of contents follows the order of file paths.
It automatically strips UTF-8 byte order mark from results.
const multipleFiles = ; // foo.txt: Hello// bar.txt: World ;
If it fails terribly it passes an error to the first argument and doesn't pass any values to the second argument. It will silent handle missing files withiut throwing an error.
const multipleFiles = ; // foo.txt: exists// bar.txt: doesn't exist// baz.txt: exists ;
Related project
- activerules-read-files-promise (Promises/A+ version)
License
Copyright (c) 2017 - Brian Winkers
Licensed under the MIT License.
Check back soon...