From 20e2411845c1007a9bf11e484b00eb50b19c9a2c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 22 Jul 2016 14:46:44 +0300 Subject: [PATCH] Use .errorfirst callback --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 55ed2c8..c788d1c 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,10 @@ module.exports.runParallel = runParallel; function runThread(generator, arg, finishCallback) { - var thread = function() { continueThread.apply(thread) }; + var thread = function() { continueThread.apply(thread, arguments) }; thread.throttle = throttleThread; thread.cb = threadCallback.bind(thread); - thread.errorfirst = errorFirst.bind(thread); + thread.ef = thread.errorfirst = errorFirst.bind(thread); thread._gen = generator(thread, arg); thread._finishThrottleQueue = finishThrottleQueue.bind(thread); thread._finishCallback = finishCallback; @@ -70,7 +70,7 @@ function threadCallback() fn._stack.replace(/^\s*Error\s*at Function\.thread\.cb\s*\([^)]*\)/, '')+'\n--' ); } - return thread.apply(thread, arguments); + return callGen(thread, 'next', Array.prototype.slice.call(arguments, 0)); }; fn._stack = new Error().stack; thread._current = fn; @@ -92,7 +92,7 @@ function errorFirst() } if (arguments[0]) return callGen(thread, 'throw', arguments[0]); - return callGen(thread, Array.prototype.slice.call(arguments, 0)); + return callGen(thread, 'next', Array.prototype.slice.call(arguments, 1)); }; fn._stack = new Error().stack; thread._current = fn;