@@ -542,7 +542,7 @@ function runFiber(util, suspended, aff, completeCb) {
542542 break ;
543543
544544 case COMPLETED :
545- completeCb ( ) ;
545+ completeCb ( step ) ;
546546 tmp = false ;
547547 for ( var k in joins ) {
548548 if ( { } . hasOwnProperty . call ( joins , k ) ) {
@@ -664,7 +664,7 @@ exports._launchAff = function (util, suspended, aff) {
664664 } ;
665665} ;
666666
667- exports . _sequential = function ( util , runAff , par ) {
667+ exports . _sequential = function ( util , par ) {
668668 function runParAff ( cb ) {
669669 // Table of all forked fibers.
670670 var fiberId = 0 ;
@@ -708,18 +708,20 @@ exports._sequential = function (util, runAff, par) {
708708 } else {
709709 // Again, we prime the effect but don't run it yet, so that we can
710710 // collect all the fibers first.
711- kills [ count ++ ] = runAff ( function ( result ) {
711+ kills [ count ++ ] = function ( aff ) {
712712 return function ( ) {
713- count -- ;
714- if ( fail === null && util . isLeft ( result ) ) {
715- fail = result ;
716- }
717- // We can resolve the callback when all fibers have died.
718- if ( count === 0 ) {
719- cb ( fail || util . right ( void 0 ) ) ( ) ;
720- }
713+ return runFiber ( util , false , aff , function ( result ) {
714+ count -- ;
715+ if ( fail === null && util . isLeft ( result ) ) {
716+ fail = result ;
717+ }
718+ // We can resolve the callback when all fibers have died.
719+ if ( count === 0 ) {
720+ cb ( fail || util . right ( void 0 ) ) ( ) ;
721+ }
722+ } ) ;
721723 } ;
722- } ) ( tmp . _1 . kill ( error ) ) ;
724+ } ( tmp . _1 . kill ( error ) ) ;
723725 }
724726 // Terminal case.
725727 if ( head === null ) {
@@ -872,11 +874,9 @@ exports._sequential = function (util, runAff, par) {
872874
873875 function resolve ( fiber ) {
874876 return function ( result ) {
875- return function ( ) {
876- delete fibers [ fiber . _1 ] ;
877- fiber . _3 = result ;
878- join ( result , fiber . _2 . _1 , fiber . _2 . _2 ) ;
879- } ;
877+ delete fibers [ fiber . _1 ] ;
878+ fiber . _3 = result ;
879+ join ( result , fiber . _2 . _1 , fiber . _2 . _2 ) ;
880880 } ;
881881 }
882882
@@ -933,7 +933,11 @@ exports._sequential = function (util, runAff, par) {
933933 // because they may all be synchronous and resolve immediately, at
934934 // which point it would attempt to resolve against an incomplete
935935 // tree.
936- fibers [ fid ] = new Aff ( THUNK , runAff ( resolve ( step ) ) ( tmp ) ) ;
936+ fibers [ fid ] = function ( aff , completeCb ) {
937+ return new Aff ( THUNK , function ( ) {
938+ return runFiber ( util , false , aff , completeCb ) ;
939+ } ) ;
940+ } ( tmp , resolve ( step ) ) ;
937941 }
938942 break ;
939943 case RETURN :
@@ -974,10 +978,6 @@ exports._sequential = function (util, runAff, par) {
974978 }
975979 }
976980
977- function ignore ( ) {
978- return function ( ) { } ;
979- }
980-
981981 // Cancels the entire tree. If there are already subtrees being canceled,
982982 // we need to first cancel those joins. This is important so that errors
983983 // don't accidentally get swallowed by irrelevant join callbacks.
@@ -987,7 +987,7 @@ exports._sequential = function (util, runAff, par) {
987987 // We can drop the fibers here because we are only canceling join
988988 // attempts, which are synchronous anyway.
989989 for ( var kid = 0 , n = killId ; kid < n ; kid ++ ) {
990- runAff ( ignore , kills [ kid ] . kill ( error ) ) ( ) ;
990+ runFiber ( util , false , kills [ kid ] . kill ( error ) , function ( ) { } ) ;
991991 }
992992
993993 var newKills = kill ( error , root , cb ) ;
@@ -997,7 +997,7 @@ exports._sequential = function (util, runAff, par) {
997997 return function ( ) {
998998 for ( var kid in newKills ) {
999999 if ( newKills . hasOwnProperty ( kid ) ) {
1000- runAff ( ignore , newKills [ kid ] . kill ( killError ) ) ( ) ;
1000+ runFiber ( util , false , newKills [ kid ] . kill ( killError ) , function ( ) { } ) ;
10011001 }
10021002 }
10031003 return nonCanceler ;
0 commit comments