Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-readfile-promise

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-readfile-promise

Promise version of fs.readFile

  • 4.0.0-0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89K
increased by8.62%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 26 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc