
正文
[Most.js] Create Streams From Single Values With Most.js
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
Most provides many means for creating streams, the simplest of which is the offunction. 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} = mostconst log =
label => value => logger(label, value);most.of('anything')
.observe(log('string'))just('anything')
.observe(log('string'))just()
.observe(log('number'))// Bonus Bits
// Lift all the things
just(true)
.observe(log('boolean'))just({ a: , b: })
.observe(log('object'))just([ , , ])
.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
*/








