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

instapromise

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instapromise

Promisify Node-style asynchronous functions by putting a .promise after them (or after the object for methods)

  • 2.0.7
  • latest
  • Source
  • npm
  • Socket score

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

Instapromise Circle CI

Promisify Node-style asynchronous functions by putting a .promise after them (or after the object for methods).

npm package

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

import 'instapromise';
import fs from 'fs';

let p = fs.readFile.promise('/tmp/hello', 'utf8');
p.then(console.log);

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

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

import 'instapromise';
import fs from 'fs';

let p = fs.promise.readFile('/tmp/hello', 'utf8');
p.then(console.log);

Changelog

2.0.7

Non-enumerable properties like class methods are now promisified. Functions with names that would cause syntax errors (like default) are supported.

2.0.3

The ___instapromiseOriginalFunction___ property is now non-enumerable so it doesn't show up when serializing functions whose promise property has been accessed before.

2.0.0

The Promise polyfill is no longer provided. 1.x provided a polyfill for environments without a native Promise implementation, but in general, most environments you'll use now provide Promise.

Credits

This code is based on the proxying code used in fibrous.

Keywords

FAQs

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

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