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

call-me-maybe

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

call-me-maybe

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

  • 1.0.2-beta.1
  • beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1M
decreased by-43.15%
Maintainers
1
Weekly downloads
 
Created

What is call-me-maybe?

The 'call-me-maybe' npm package is designed to handle callbacks and promises in a unified way. It allows developers to write functions that can return a promise if no callback is provided, or execute a callback if one is given. This flexibility makes it easier to work with asynchronous code in JavaScript.

What are call-me-maybe's main functionalities?

Handling callbacks and promises

This feature allows a function to handle both callbacks and promises. If a callback is provided, it is called with the result; otherwise, a promise is returned. The code sample demonstrates how to implement a simple asynchronous operation that can be used either way.

const maybe = require('call-me-maybe');

function asyncOperation(callback) {
  return maybe(callback, new Promise((resolve, reject) => {
    setTimeout(() => resolve('Done!'), 1000);
  }));
}

// Using with callback
asyncOperation(result => console.log(result));

// Using as a promise
asyncOperation().then(result => console.log(result));

Other packages similar to call-me-maybe

Keywords

FAQs

Package last updated on 31 Oct 2022

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