🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

make-promise

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-promise

A function that creates a Promises/A+ promise.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

make-promise Build Status Dependency Status

A function that creates a Bluebird promise that can be resolved or rejected using a Node-style callback.

Usage

make-promise exports a single function, which takes a function as it sole argument. After you have called makePromise, this function is called immediately afterwards with a Node-style callback as its sole argument.

  • Calling the callback with a truthy error argument will cause the promise to be rejected with the value of the error argument.
  • Calling the callback with a falsy error argument will cause the promise to be fulfilled with the value of the result argument. If there is no result argument, the promise will be fulfilled with undefined.

Code example

var skyIsFalling = false
var makePromise = require("make-promise")
var promise = makePromise(function(cb) {
  setImmediate(function() {
    if skyIsfalling
      cb(new Error("Sky is falling."))
    else
      cb()
  })
})
promise.then(
  function(){
    // phew!
  },
  function(err) {
    console.error err.toString() + " Better take cover."
  })

License

make-promise is released under the MIT License.
Copyright (c) 2017 Braveg1rl

FAQs

Package last updated on 03 Jan 2017

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