Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active February 3, 2016 22:05
Show Gist options
  • Save davidchase/2d12eaec551341a77601 to your computer and use it in GitHub Desktop.
Save davidchase/2d12eaec551341a77601 to your computer and use it in GitHub Desktop.
Most Operators
// 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