An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# fs-read-queue [![NPM version](https://badge.fury.io/js/fs-read-queue.svg)](http://badge.fury.io/js/fs-read-queue) [![Build Status](https://travis-ci.org/doowb/fs-read-queue.svg)](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._