0.0.1 • Published 9 years ago

rob-util v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Build Test Coverage

rob-util

rob-util is a NodeJs module I authored for basic common functions that would get shared between various node modules.

Status : ALPHA (unstable)

Random

Callback helper

var ru = require('rob-util');

callbackThrow

This method abstracts the task of throwing an error on a async method.

This is what an standard async throw method will look like typically: function getContact(id, cb) { db.getContact(id, function(err, data) { if(err) throw err; cb(null, data); }); }

This can get reduced to: function getContact(id, cb) { db.getContact(id, ru.cb.callbackThrow(cb)); }

callbackReturn

This method abstracts the task of throwing an error on a async method.

This is what an standard async throw method will look like typically: function getContact(id, cb) { db.getContact(id, function(err, data) { cb(err, data); }); }

This can get reduced to: function getContact(id, cb) { db.getContact(id, ru.cb.callbackReturn(cb)); }