Socket
Socket
Sign inDemoInstall

call-me-maybe

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    call-me-maybe

Let your JS API users either give you a callback or receive a promise


Version published
Weekly downloads
5.8M
decreased by-18.48%
Maintainers
1
Install size
8.41 kB
Created
Weekly downloads
 

Readme

Source

call-me-maybe Build Status

Let your JS API users either give you a callback or receive a promise.

Usage

var maybe = require("call-me-maybe")

module.exports = function asyncFunc (cb) {
  return maybe(cb, new Promise(function(resolve, reject) {
    // ...
  }))
}

API

maybe(cb, promise)

If the callback cb is truthy, returns undefined and will call cb when promise is settled. The parameters passed to cb are standard error-first:

  • If promise is fulfilled, then it is called with the result of the promise: cb(null, result)
  • If promise is rejected, then it is called with the rejection error: cb(err)

If cb is falsey, then promise is retuned.

Keywords

FAQs

Last updated on 12 Sep 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc