Socket
Socket
Sign inDemoInstall

add-callback-to-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    add-callback-to-promise

npm i --save add-callback-to-promise


Version published
Maintainers
1
Install size
2.14 kB
Created

Readme

Source

Install

npm i --save add-callback-to-promise

Use

Makes it easier to create a function which returns a Promise but also allows a user to specify a callback.

Example

const addCallbackToPromise = require('add-callback-to-promise')

function somethingLongrunning(options, callback /*optional*/)
	let p = new Promise((resolve, reject) => {
		// Some code here

		if(err) {
			return reject(err)
		}
		resolve(result)
	})
	return addCallbackToPromise(p, callback)
}

FAQs

Last updated on 26 May 2021

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