Most provides many means for creating streams, the simplest of which is the of
function. In this lesson, we demonstrate the use of of
to lift a single value into a stream. We also show off the just
alias of of
, as well as, a common method for currying a function.
Use CDN:
most.of('anything') console.log(stream) // { source: { value: 'anything' } }
Use require:
const { just , of} = most const log = label => value => logger(label, value); most.of('anything') .observe(log('string')) just('anything') .observe(log('string')) just(23) .observe(log('number')) // Bonus Bits // Lift all the things just(true) .observe(log('boolean')) just({ a: 1, b: 2 }) .observe(log('object')) just([ 1, 2, 3]) .observe(log('array')) just(x => x) .observe(log('function')) just(undefined) .observe(log('undefined')) /* string: 'anything' string: 'anything' number: 23 boolean: true object: { a: 1, b: 2 } array: [ 1, 2, 3 ] function: Function undefined: undefined */