Baconjs Static API

node v14.20.1
version: 1.0.0
endpointsharetweet
const R = require('ramda'), B = require('baconjs'), // scan :: ((a, b) -> a) -> a -> Observable b -> Observable a scan = R.curry((reducer, seed, observable) => observable.scan(seed, reducer)), // filter:: (a -> Boolean) -> Observable a -> Observable a filter = R.curry((predicateOrProperty, observable) => observable.filter(predicateOrProperty)), // combine :: (a -> b -> c) -> Observable a -> Observable b -> Property c combine = R.curry((combiner, left, right) => left.combine(right, combiner)), map = R.curry((fn, observable) => observable.map(fn)), skip = R.curry((count, observable) => observable.skip(count)), words = B.sequentially(600, ["Abra", "Bebra", "Aura", "Alpha"]), begin = Date.now(), wholeSeconds = B.fromPoll(1000, () => Math.round((Date.now() - begin) / 1000)).takeUntil(B.later(2500, undefined)).toProperty(0); allAwords = R.pipe( filter(R.startsWith("A")), scan(R.flip(R.append), []), skip(1) ) (words), wordsWithLength = R.pipe( map(R.objOf("word")), map(R.chain(R.assoc("length"), val => val.word.length)), combine(R.assoc("time"), wholeSeconds) )(words); allAwords.onValue(x => console.log(`Awords:${x}`)); wordsWithLength.onValue(x => console.log(x));
Loading…

no comments

    sign in to comment