Skip to content

Commit

Permalink
Update built files
Browse files Browse the repository at this point in the history
  • Loading branch information
aearly committed May 22, 2017
1 parent b4c80c0 commit 05137e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
43 changes: 21 additions & 22 deletions dist/async.js
Expand Up @@ -4868,34 +4868,33 @@ function sortBy (coll, iteratee, callback) {
* });
*/
function timeout(asyncFn, milliseconds, info) {
var originalCallback, timer;
var timedOut = false;

function injectedCallback() {
if (!timedOut) {
originalCallback.apply(null, arguments);
clearTimeout(timer);
}
}
var fn = wrapAsync(asyncFn);

function timeoutCallback() {
var name = asyncFn.name || 'anonymous';
var error = new Error('Callback function "' + name + '" timed out.');
error.code = 'ETIMEDOUT';
if (info) {
error.info = info;
return initialParams(function (args, callback) {
var timedOut = false;
var timer;

function timeoutCallback() {
var name = asyncFn.name || 'anonymous';
var error = new Error('Callback function "' + name + '" timed out.');
error.code = 'ETIMEDOUT';
if (info) {
error.info = info;
}
timedOut = true;
callback(error);
}
timedOut = true;
originalCallback(error);
}

var fn = wrapAsync(asyncFn);
args.push(function () {
if (!timedOut) {
callback.apply(null, arguments);
clearTimeout(timer);
}
});

return initialParams(function (args, origCallback) {
originalCallback = origCallback;
// setup timer and call original function
timer = setTimeout(timeoutCallback, milliseconds);
fn.apply(null, args.concat(injectedCallback));
fn.apply(null, args);
});
}

Expand Down

0 comments on commit 05137e6

Please sign in to comment.