fix for promises

master
Vitaliy Filippov 2016-08-17 18:49:05 +03:00
parent c4c935bbc1
commit f7fe35fce2
2 changed files with 4 additions and 9 deletions

View File

@ -33,7 +33,8 @@ function runThread(generator, onsuccess, onerror)
var thread = function()
{
thread._current = null;
continueThread.apply(thread, arguments);
// pass parameters as yield result
callGen(thread, 'next', Array.prototype.slice.call(arguments, 0));
};
thread._gen = generator.next ? generator : generator();
thread._finishThrottleQueue = finishThrottleQueue.bind(thread);
@ -44,12 +45,6 @@ function runThread(generator, onsuccess, onerror)
return thread;
}
function continueThread()
{
// pass parameters as yield result
callGen(this, 'next', Array.prototype.slice.call(arguments, 0));
}
function getStack(fn)
{
return fn._stack.replace(/Error[\s\S]*at.*(exports\.(cb|ef|errorfirst)|Function\.(errorFirst|threadCallback)).*/, '');
@ -106,7 +101,7 @@ function callGen(thread, method, arg)
else if (typeof v.value == 'object' && v.value.then)
{
// check if v.value is a Promise
var cb = threadCallback.call(current);
var cb = threadCallback.call(thread);
v.value.then(cb, function(error)
{
callGen(thread, 'throw', error);

View File

@ -1,6 +1,6 @@
{
"name": "gen-thread",
"version": "1.0.0",
"version": "1.0.1",
"author": {
"name": "Vitaliy Filippov",
"email": "vitalif@yourcmc.ru"