Socket
Socket
Sign inDemoInstall

success

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    success

Success/failure handler for Node.js callbacks


Version published
Weekly downloads
110
increased by7.84%
Maintainers
1
Install size
3.05 kB
Created
Weekly downloads
 

Readme

Source

success

Success/failure handler for Node.js callbacks

A convenience function for passing errors to a callback that helps you avoid the need to write

if( error ) return callback( error );

all the time.

Instead, you can do this:

var success = require('success')

function doStuff( err, callback ) {

  doMoreStuff( success(callback, function(result) {

    handleResult( result )
  }))  
}

This replaces the plain version:

var success = require('success')

function doStuff( err, callback ) {

  doMoreStuff( function( err, result ) {
    if( err ) return callback(err);

    handleResult( result )
  })
}

If you want to be quick and dirty, omitting the failure callback will print the error (if it occurs) to standard output.

  doMoreStuff( success(function(result) {

    handleResult( result )
  }))  

Support

If you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger

Current Version: 0.1.0

Tested on: node 0.10.24

Build
Status

Keywords

FAQs

Last updated on 27 Mar 2014

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