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

instapromise

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instapromise

Promisify node style async functions by putting a .promise after them (or after the object for methods)

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
609
increased by74%
Maintainers
1
Weekly downloads
 
Created
Source

instapromise

Promisify node style async functions by putting a .promise after them (or after the object for methods)

If you use this library then if you put .promise after a Node-style async function, it will turn it into a function that returns a Promise instead of taking a callback.

The original function is available as a property on the Promise generating function (.___instapromiseOriginalFunction___).

  promisify = require 'instapromise'
  p = fs.readFile.promise "/tmp/hello", 'utf8'
  p.then(console.log)

If you want to promisify methods, use .promise after the object and before the method name.

  promisify = require 'instapromise'
  p = fs.promise.readFile "/tmp/hello", 'utf8'
  p.then(console.log)

This code is based on the proxying code used in fibrous. https://github.com/goodeggs/fibrous/blob/master/src/fibrous.coffee

Keywords

FAQs

Package last updated on 08 Feb 2015

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