Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/fs-readdir-promise
Promises/A+ version of fs.readdir
https://github.com/shinnn/fs-readdir-promise
Last synced: 26 days ago
JSON representation
Promises/A+ version of fs.readdir
- Host: GitHub
- URL: https://github.com/shinnn/fs-readdir-promise
- Owner: shinnn
- License: mit
- Created: 2014-11-18T07:05:05.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-03T22:28:17.000Z (over 8 years ago)
- Last Synced: 2024-04-14T10:53:45.129Z (7 months ago)
- Language: JavaScript
- Homepage: http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback
- Size: 152 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fs-readdir-promise
[![Build Status](https://img.shields.io/travis/shinnn/fs-readdir-promise.svg?style=flat)](https://travis-ci.org/shinnn/fs-readdir-promise)
[![Build status](https://ci.appveyor.com/api/projects/status/401attqixqs2jofe?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/fs-readdir-promise)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/fs-readdir-promise.svg?style=flat)](https://coveralls.io/r/shinnn/fs-readdir-promise)
[![Dependency Status](https://david-dm.org/shinnn/fs-readdir-promise.svg?style=flat)](https://david-dm.org/shinnn/fs-readdir-promise)
[![devDependency Status](https://david-dm.org/shinnn/fs-readdir-promise/dev-status.svg?style=flat)](https://david-dm.org/shinnn/fs-readdir-promise#info=devDependencies)[Promises/A+][Promise] version of [`fs.readdir`](http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback)
```javascript
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 version](https://img.shields.io/npm/v/fs-readdir-promise.svg?style=flat)](http://badge.fury.io/js/fs-readdir-promise)
[Use npm.](https://www.npmjs.org/doc/cli/npm-install.html)
```sh
npm install fs-readdir-promise
```## API
```javascript
var readdir = require('fs-readdir-promise');
```### readdir(*path*)
*path*: `String`
Return: `Object` ([Promise])When it finish reading the directory, it will be [*fulfilled*](http://promisesaplus.com/#point-26) with an `Array` of file names in the directory as its first argument.
When it fails to read the directory, it will be [*rejected*](http://promisesaplus.com/#point-30) with an error as its first argument.
```javascript
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](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).
[fsreaddir]: http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback
[Promise]: http://promisesaplus.com/