Permalink
Browse files

Added applySync method. Issue: caolan/async#208

  • Loading branch information...
1 parent 914fa10 commit e1490e05e77834285ddf691dbc39b1aff1943d02 @sfrdmn committed Feb 7, 2013
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/async.js
View
@@ -583,6 +583,23 @@
};
};
+ async.applySync = function (fn) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return function () {
+ var argsTask = Array.prototype.slice.call(arguments);
+ var callback = argsTask.pop();
+ var result;
+ try {
+ result = fn.apply(null, args.concat(argsTask));
+ async.nextTick(callback);
+ return result;
+ }
+ catch (err) {
+ callback(err);
+ }
+ };
+ };
+
var _concat = function (eachfn, arr, fn, callback) {
var r = [];
eachfn(arr, function (x, cb) {

0 comments on commit e1490e0

Please sign in to comment.