# fs-readfile-promise

> Promise version of fs.readFile

Latest version **3.0.1** (published 2017-12-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install fs-readfile-promise
pnpm add fs-readfile-promise
yarn add fs-readfile-promise
bun add fs-readfile-promise
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2017-12-26 |
| First published | 2014-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/fs-readfile-promise) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | fs, read, file, promise, promises, then, thenable |

## Links

- npm: https://www.npmjs.com/package/fs-readfile-promise
- Repository: https://github.com/shinnn/fs-readfile-promise
- Homepage: https://github.com/shinnn/fs-readfile-promise#readme
- Issues: https://github.com/shinnn/fs-readfile-promise/issues
- npm.io page: https://npm.io/package/fs-readfile-promise

## Dependencies (1)

- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.11

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2017-12-26
- 4.0.0-2 (next) — 2017-12-27
- 4.0.0-1 — 2017-12-26
- 4.0.0-0 — 2017-12-26
- 3.0.0 — 2016-05-25
- 2.0.1 — 2015-07-07
- 2.0.0 — 2015-05-30
- 1.1.0 — 2014-12-07
- 1.0.1 — 2014-10-19
- 1.0.0 — 2014-09-07
- 0.1.0 — 2014-08-07
- 0.0.0 — 2014-08-06

## README

# fs-readfile-promise

[![npm version](https://img.shields.io/npm/v/fs-readfile-promise.svg)](https://www.npmjs.com/package/fs-readfile-promise)
[![Build Status](https://travis-ci.org/shinnn/fs-readfile-promise.svg?branch=master)](https://travis-ci.org/shinnn/fs-readfile-promise)
[![Build status](https://ci.appveyor.com/api/projects/status/5sacvq0w9x7mwkwd?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/fs-readfile-promise)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/fs-readfile-promise.svg)](https://coveralls.io/r/shinnn/fs-readfile-promise)

Promisified version of [`fs.readFile`][fs.readfile]

```javascript
const readFilePromise = require('fs-readfile-promise');

(async () => {
  const buffer = await readFile('path/to/a/file');
  buffer.toString(); //=> '... file contents ...'
})();
```

Based on the principle of [*modular programming*](https://en.wikipedia.org/wiki/Modular_programming), this module has only one functionality [`readFile`][fs.readfile], unlike other Promise-based file system modules. If you'd like to use a bunch of other [`fs`](http://nodejs.org/api/fs.html) methods in the Promise way, choose other modules such as [q-io](https://github.com/kriskowal/q-io) and [promise-fs](https://github.com/octet-stream/promise-fs).

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).

```
npm install fs-readfile-promise
```

## API

```javascript
const readFilePromise = require('fs-readfile-promise');
```

### readFile(*path* [, *options*])

*path*: `string` `Buffer` `URL` `integer`  
*options*: `Object` ([fs.readFile] options) or `string` (encoding)  
Return: `Promise<Buffer|string>`

```javascript
(async () => {
  await readFilePromise('src.txt'); //=> <Buffer 48 69 2e>
  await readFilePromise('src.txt', 'utf8'); //=> 'Hi.'
  await readFilePromise('src.txt', {encoding: 'base64'}); //=> 'SGku'
})();

```

## License

[ISC License](./LICENSE) © 2017 Shinnosuke Watanabe

[fs.readfile]: https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback

---
_Source: https://npm.io/package/fs-readfile-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
