🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

promisify-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promisify-api

Changes interface of asynchronous functions to Promises

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

promisify-api

Changes interface of asynchronous functions to Promises. Functions should be designed using error-first callback pattern.

Installation

$ npm install promisify-api

Usage

promisify(fn, ctx, _)

Creates a wrapper function, which returns Promises.

const fs = require('fs');
const resolve = require('path').resolve;
const promisify = require('promisify-api');

// the second argument (which is context) is optional
const readFile = promisify(fs.readFile, fs);

readFile(resolve('index.js'), 'utf8')
  .then(console.log)
  .catch(console.error);

Arguments:

  • fn (function): The original function.
  • ctx (*): Predefines execution context of the original function.
  • ..._ (*): Possibility to provide additional arguments, that will be prepended to the function.

License

The MIT License

Keywords

promise

FAQs

Package last updated on 12 Apr 2016

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