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

  • 0.1.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 Dependency Status devDependency Status

Promise version of fs.readFile

var readFile = require('fs-readfile-promise');

readFile('path/to/file')
.then(function(buffer) {
  console.log(buffer.toString());
})
.catch(function(err) {
  console.log(err.message);
});

This performs only a single task, based on the principle of modular programming. If you want to use a bunch of other fs methods in the way of promise, choose other modules such as q-io and fs-promise.

Installation

Install with npm. (Make sure you have installed Node)

npm install --save fs-readfile-promise

API

var readFile = require('fs-readfile-promise');

readFile(filename [, options])

filename: String
options: Object (same as fs.readFile)
Return: Object (Promise)

When it finish reading the file, it will be fulfilled with an Buffer of the file as its first argument.

When it fails to read the file, it will be rejected with an error as its first argument.

var readFile = require('fs-readfile-promise');

var onFulfilled = function(buffer) {
  console.log(buffer.toString());
};

var onRejected = function(err) {
  console.log('Cannot read the file.');
};

readFile('path/to/file').then(onFulfilled, onRejected);

License

Copyright (c) 2014 Shinnosuke Watanabe

Licensed under the MIT LIcense.

Keywords

FAQs

Package last updated on 07 Aug 2014

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