XuelesszzZ 94af2b8e7b 6-30-5 | il y a 1 an | |
---|---|---|
.. | ||
test | il y a 1 an | |
.npmignore | il y a 1 an | |
LICENSE | il y a 1 an | |
README.md | il y a 1 an | |
index.coffee | il y a 1 an | |
index.js | il y a 1 an | |
package.json | il y a 1 an |
Higher-order functions for easier error handling.
if (err) return cb(err);
be gone!
npm install iferr
var iferr = require('iferr');
function get_friends_count(id, cb) {
User.load_user(id, iferr(cb, function(user) {
user.load_friends(iferr(cb, function(friends) {
cb(null, friends.length);
}));
}));
}
iferr = require 'iferr'
get_friends_count = (id, cb) ->
User.load_user id, iferr cb, (user) ->
user.load_friends iferr cb, (friends) ->
cb null, friends.length
(TODO: document tiferr, throwerr and printerr)
MIT