Last active
April 22, 2016 02:50
-
-
Save elsehow/45f72854e0562af068cf242dcb929909 to your computer and use it in GitHub Desktop.
This file contains 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
const Kefir = require('kefir') | |
// NO MODES | |
// EVERYTHING IS COMMANDS | |
// EVEN IF SOME COMMANDS ARE AUTO-POPULATE | |
function api (param) { | |
// here we can close over some mutable state | |
// if we need to | |
return (inputS) => { | |
let outputS = Kefir.pool() | |
let inputValS = Kefir.pool() | |
let oneS = inputS | |
.filter(x => x==1) | |
outputS.plug(oneS) | |
let twoS = inputS | |
.filter(x => x==2) | |
.map(x => x+param) | |
inputValS.plug(twoS) | |
return [outputS, inputValS] | |
} | |
} | |
// tests | |
let commandS = require('kefir') // mock input | |
.sequentially(100, [1,2,3]) | |
let [outputS, inputValS] = api('some-arg')(commandS) | |
outputS.log('output') | |
inputValS.log('input value') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment