Last active
February 3, 2016 22:05
-
-
Save davidchase/2d12eaec551341a77601 to your computer and use it in GitHub Desktop.
Most Operators
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
// experiment operators for most.js :D | |
import {from, of} from 'most'; | |
import {complement} from 'ramda'; | |
const siphon = (pred, fn, stream) => from([stream.filter(pred).tap(fn).chain(most.empty), stream.filter(complement(pred))]).join(); | |
const partition = (pred, stream) => from([stream.filter(pred), stream.filter(complement(pred))]); | |
const partitionList = (pred, stream) => [stream.filter(pred), stream.filter(complement(pred))]; // [Streams] | |
siphon(x => x % 2 === 0, () => console.log('side-effect'), of(2)); // => side-effect | |
siphon(x => x % 2 === 0, () => console.log('side-effect'), of(3)); // 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment