fs-readdir-promise
v1.0.1
Published
Promises/A+ version of fs.readdir
Downloads
39
Maintainers
Readme
fs-readdir-promise
Promises/A+ version of fs.readdir
var readdir = require('fs-readdir-promise');
readdir('path/to/dir')
.then(function(files) {
console.log(files);
})
.catch(function(err) {
console.log(err.message);
});
Installation
npm install fs-readdir-promise
API
var readdir = require('fs-readdir-promise');
readdir(path)
path: String
Return: Object
(Promise)
When it finish reading the directory, it will be fulfilled with an Array
of file names in the directory as its first argument.
When it fails to read the directory, it will be rejected with an error as its first argument.
var readdir = require('fs-readdir-promise');
var onFulfilled = function(files) {
console.log(files);
};
var onRejected = function(err) {
console.log('Cannot read the file.');
};
readdir('path/to/file').then(onFulfilled, onRejected);
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.