.. | ||
test | ||
.npmignore | ||
index.coffee | ||
index.js | ||
LICENSE | ||
package.json | ||
README.md |
iferr
Higher-order functions for easier error handling.
if (err) return cb(err);
be gone!
Install
npm install iferr
Use
JavaScript example
var iferr = require('iferr');
function get_friends_count(id, cb) {
.load_user(id, iferr(cb, function(user) {
User.load_friends(iferr(cb, function(friends) {
usercb(null, friends.length);
;
}));
})) }
CoffeeScript example
= require 'iferr'
iferr
= (id, cb) ->
get_friends_count .load_user id, iferr cb, (user) ->
User.load_friends iferr cb, (friends) ->
usernull, friends.length cb
(TODO: document tiferr, throwerr and printerr)
License
MIT