suc

success

Success/failure handler for Node.js callbacks

Showing:

Popularity

Downloads/wk

375

GitHub Stars

0

Maintenance

Last Commit

8yrs ago

Contributors

1

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial