Skip to content

Instantly share code, notes, and snippets.

@gkatsev
Created September 1, 2015 21:35
Show Gist options
  • Save gkatsev/947481cce1bb3d4d5fb9 to your computer and use it in GitHub Desktop.
Save gkatsev/947481cce1bb3d4d5fb9 to your computer and use it in GitHub Desktop.
var async = require('async');
var swap = function(f) {
return function(callback) {
f(function(e, a) {
callback(a, e);
})
};
};
module.exports = function tryAll(tasks, callback) {
async.series(tasks.map(swap), function(err, results) {
if (err) {
return callback(null, err);
}
callback(results, err);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment