Skip to content

Commit

Permalink
Use ducktyping in interpretor to determine whether to flat map
Browse files Browse the repository at this point in the history
This allows the interpretor to be a static export without
dependency injection, but more importantly, it allows the
interpretor to absorb Futures produced by actions which return
Futures created by another compatible version of Fluture.
  • Loading branch information
Avaq committed Jun 7, 2017
1 parent 52ae333 commit 9c5900b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ Sequence.prototype._finally = function Sequence$finally(other){
return this._transform(new FinallyAction(other));
};

Sequence.prototype._fork = interpretor(Sequence);
Sequence.prototype._fork = interpretor;

Sequence.prototype.toString = function Sequence$toString(){
return `${this._spawn.toString()}${this._actions.map(x => `.${x.toString()}`).join('')}`;
Expand Down
6 changes: 3 additions & 3 deletions src/internal/interpretor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Denque from 'denque';
import {noop} from './fn';

export default Sequence => function interpretor(rej, res){
export default function interpretor(rej, res){

//This is the primary queue of actions. All actions in here will be "cold",
//meaning they haven't had the chance yet to run concurrent computations.
Expand All @@ -29,7 +29,7 @@ export default Sequence => function interpretor(rej, res){
function settle(m){
settled = true;
future = m;
if(future instanceof Sequence){
if(future._spawn){
for(let i = future._actions.length - 1; i >= 0; i--) cold.unshift(future._actions[i]);
future = future._spawn;
}
Expand Down Expand Up @@ -123,4 +123,4 @@ export default Sequence => function interpretor(rej, res){
while(it = queue.shift()) it.cancel();
};

};
}

0 comments on commit 9c5900b

Please sign in to comment.