Skip to content

Instantly share code, notes, and snippets.

@elsehow
Last active April 22, 2016 02:50
Show Gist options
  • Save elsehow/45f72854e0562af068cf242dcb929909 to your computer and use it in GitHub Desktop.
Save elsehow/45f72854e0562af068cf242dcb929909 to your computer and use it in GitHub Desktop.
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