https://github.com/doowb/fs-read-queue
Queue `fs.readFile` calls to the same file path.
https://github.com/doowb/fs-read-queue
Last synced: over 1 year ago
JSON representation
Queue `fs.readFile` calls to the same file path.
- Host: GitHub
- URL: https://github.com/doowb/fs-read-queue
- Owner: doowb
- License: mit
- Created: 2015-07-01T04:46:01.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T02:59:24.000Z (almost 11 years ago)
- Last Synced: 2024-10-11T03:59:48.882Z (almost 2 years ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fs-read-queue [](http://badge.fury.io/js/fs-read-queue) [](https://travis-ci.org/doowb/fs-read-queue)
> Queue `fs.readFile` calls to the same file path.
> The code in this module is inspired by the work done by [mhiguera](https://github.com/mhiguera) in [this pull request](https://github.com/tj/consolidate.js/pull/171).
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i fs-read-queue --save
```
## Usage
```js
var readFile = require('fs-read-queue');
```
## API
### [readFile](index.js#L35)
File reading function that will queue up calls to `fs.readFile` for the same filepath to prevent `ENFILE` errors.
**Params**
* `fp` **{String}**: File path to read
* `options` **{String}**: Additional options to pass to ` fs.readFile`
* `cb` **{Function}**: Callback function that takes `err` and `contents` parameters. Will be called when the file is read.
**Example**
```js
readFile('path/to/my/file', function (err, contents) {
if (err) return console.error(err);
console.log(contents);
});
```
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/fs-read-queue/issues/new)
## Author
**Brian Woodward**
+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)
## License
Copyright © 2015 Brian Woodward
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 01, 2015._