fs-readfile-promise
Promise version of fs.readFile
Last updated 8 years ago by shinnn .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fs-readfile-promise 
SYNC missed versions from official npm registry.

fs-readfile-promise

npm version Build Status Build status Coverage Status

Promisified version of fs.readFile

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, this module has only one functionality readFile, unlike other Promise-based file system modules. If you'd like to use a bunch of other fs methods in the Promise way, choose other modules such as q-io and promise-fs.

Installation

Use npm.

npm install fs-readfile-promise

API

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>

(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 © 2017 Shinnosuke Watanabe

Current Tags

  • 3.0.1                                ...           latest (8 years ago)
  • 4.0.0-2                                ...           next (8 years ago)

12 Versions

  • 4.0.0-2                                ...           8 years ago
  • 4.0.0-1                                ...           8 years ago
  • 4.0.0-0                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           10 years ago
  • 2.0.1                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
  • 0.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |