This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delay(expressionAsFunction) { | |
var result; | |
var isEvaluated = false; | |
return function () { | |
if (!isEvaluated) | |
result = expressionAsFunction(); | |
return result; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Queue { | |
constructor( cb ) { | |
if( !cb ) { | |
throw new Error( 'You must specified callback'); | |
} | |
this._cb = cb; | |
} | |
push( data ) { | |
this._cb( data ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chan = function () { | |
return []; | |
}; | |
var toString = Object.prototype.toString; | |
function go( machine, chan ) { | |
var gen = machine( chan ); | |
_go( gen, gen.next() ); | |
} |
NewerOlder