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

afterward

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afterward

Execute an error-first callback upon resolution or rejection of a promise (and return the promise)

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.6K
decreased by-24.47%
Maintainers
1
Weekly downloads
 
Created
Source

afterward

NPM version Build Status Coverage Status Sauce Test Status

Execute an error-first callback upon resolution or rejection of a promise, and return the promise.

This makes it easier to write functions that support both callback and promise based async patterns.

example

var afterward = require('afterward'),
    Promise   = require('promise-polyfill')

function greet (name, cb) {
    var prom = new Promise(function (resolve) {
        setTimeout(resolve.bind(undefined, 'greetings ' + name), 100)
    })
    return afterward(prom, cb)
}

// we can now use our fancy function either way...
// with a callback:
greet('jason', function (err, msg) {
    if (err) return console.error(err)
    console.log(msg)
})

// or a promise
greet('gege').then(console.log).catch(console.error)

api

var afterward = require('afterward')

prom = afterward(prom [, cb])

Upon resolution or rejection of the promise prom, execute the optional error-first style callback cb. The promise prom is returned.

errors

var UnknownError = require('afterward/errors').UnknownError
UnknownError

The constructor function of the Error object provided to callback cb when the Promise prom is rejected with no argument.

testing

npm test [--dot | --spec] [--phantom] [--grep=pattern]

Specifying --dot or --spec will change the output from the default TAP style. Specifying --phantom will cause the tests to run in the headless phantom browser instead of node. Specifying --grep will only run the test files that match the given pattern.

browser test

npm run browser-test

This will run the tests in all browsers (specified in .zuul.yml). Be sure to educate zuul first.

coverage

npm run coverage [--html]

This will output a textual coverage report. Including --html will also open an HTML coverage report in the default browser.

Keywords

FAQs

Package last updated on 11 Sep 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