Last active
August 29, 2015 14:00
-
-
Save reggi/11186741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var _ = require("underscore"); | |
var range = _.range(0, 23); | |
var collect = function(callback){ | |
return function(){ | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift(null); | |
return callback(null, args); | |
} | |
} | |
async.map(range, function(number, callback){ | |
var callback = collect(callback); | |
if(number % 2) return callback(new Error("is odd"), number); | |
return callback(null, number); | |
}, function(err, results){ | |
console.log(err); | |
console.log(results); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment