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

create-thenable

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-thenable

Create a thenable for a given Promise prototype

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-22.93%
Maintainers
1
Weekly downloads
 
Created
Source

create-thenable Build Status

Create a thenable for a given Promise

Install

$ npm install --save create-thenable

Usage

var createThenable = require('create-thenable');
var thenable = createThenable(require('bluebird'));
return thenable.catch(errHandlers).then(handler)

The returned thenable has a then method that creates a new promise. It also proxies methods from the prototype and guarantees the presence of catch and finally. When these proxied methods are called, they call then to create the promise and then call the method on the result. That way you can do this:

var thenable = createThenable(require('bluebird'), function () {
  resolve('foo')
})


thenable.tap(function () {
  console.log('succeeded')
})
.then(function (value) {
  assert(value, 'foo')
})

thenable isn't a true Bluebird Promise but you can still trigger its methods as if it were.

API

createThenable(Promise, resolver)

Promise

Required Type: function

A Promise constructor

resolver

Required Type: function

The resolver function to pass to the Promise constructor

License

MIT © Ben Drucker

Keywords

FAQs

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