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

promise-from-callback

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-from-callback

Plugin for promisifying Node.js style callbacks into Promises

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

promise-from-callback

npm version

Plugin for promisifying Node.js style callbacks into Promises.

Compatible with all valid Promises/A+ implementations including bluebird, Q, etc..

Example

const fs = require('fs');

// Just requiring the module will extend the existing Promise API
require('promise-from-callback');

Promise
  .fromCallback(callback => fs.readFile('filename.txt', callback))
  .then(buffer => buffer.toString().trim())
  .fromCallback((filename, callback) => fs.readFile(filename, callback))
  // ...

Installation

NPM

npm install promise-from-callback

Browser

<script type="application/javascript" src="promise-from-callback.js"></script>

API Reference

Promise.fromCallback(fn[, thisArg])

Promise
  .fromCallback(callback => fs.readFile('test.txt', callback))
  .then(console.log)

Promise#fromCallback(fn[, thisArg])

Promise
  .resolve('test.txt')
  .fromCallback((filename, callback) => fs.readFile(filename, callback))
  .then(console.log);

Keywords

FAQs

Package last updated on 18 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