@@ -542,7 +542,7 @@ function runFiber(util, suspended, aff, completeCb) {
542
542
break ;
543
543
544
544
case COMPLETED :
545
- completeCb ( ) ;
545
+ completeCb ( step ) ;
546
546
tmp = false ;
547
547
for ( var k in joins ) {
548
548
if ( { } . hasOwnProperty . call ( joins , k ) ) {
@@ -664,7 +664,7 @@ exports._launchAff = function (util, suspended, aff) {
664
664
} ;
665
665
} ;
666
666
667
- exports . _sequential = function ( util , runAff , par ) {
667
+ exports . _sequential = function ( util , par ) {
668
668
function runParAff ( cb ) {
669
669
// Table of all forked fibers.
670
670
var fiberId = 0 ;
@@ -708,18 +708,20 @@ exports._sequential = function (util, runAff, par) {
708
708
} else {
709
709
// Again, we prime the effect but don't run it yet, so that we can
710
710
// collect all the fibers first.
711
- kills [ count ++ ] = runAff ( function ( result ) {
711
+ kills [ count ++ ] = function ( aff ) {
712
712
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
+ } ) ;
721
723
} ;
722
- } ) ( tmp . _1 . kill ( error ) ) ;
724
+ } ( tmp . _1 . kill ( error ) ) ;
723
725
}
724
726
// Terminal case.
725
727
if ( head === null ) {
@@ -872,11 +874,9 @@ exports._sequential = function (util, runAff, par) {
872
874
873
875
function resolve ( fiber ) {
874
876
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 ) ;
880
880
} ;
881
881
}
882
882
@@ -933,7 +933,11 @@ exports._sequential = function (util, runAff, par) {
933
933
// because they may all be synchronous and resolve immediately, at
934
934
// which point it would attempt to resolve against an incomplete
935
935
// 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 ) ) ;
937
941
}
938
942
break ;
939
943
case RETURN :
@@ -974,10 +978,6 @@ exports._sequential = function (util, runAff, par) {
974
978
}
975
979
}
976
980
977
- function ignore ( ) {
978
- return function ( ) { } ;
979
- }
980
-
981
981
// Cancels the entire tree. If there are already subtrees being canceled,
982
982
// we need to first cancel those joins. This is important so that errors
983
983
// don't accidentally get swallowed by irrelevant join callbacks.
@@ -987,7 +987,7 @@ exports._sequential = function (util, runAff, par) {
987
987
// We can drop the fibers here because we are only canceling join
988
988
// attempts, which are synchronous anyway.
989
989
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 ( ) { } ) ;
991
991
}
992
992
993
993
var newKills = kill ( error , root , cb ) ;
@@ -997,7 +997,7 @@ exports._sequential = function (util, runAff, par) {
997
997
return function ( ) {
998
998
for ( var kid in newKills ) {
999
999
if ( newKills . hasOwnProperty ( kid ) ) {
1000
- runAff ( ignore , newKills [ kid ] . kill ( killError ) ) ( ) ;
1000
+ runFiber ( util , false , newKills [ kid ] . kill ( killError ) , function ( ) { } ) ;
1001
1001
}
1002
1002
}
1003
1003
return nonCanceler ;
0 commit comments