[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} = 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
*/
复制代码

 

posted @   Zhentiw  阅读(197)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2016-01-12 [Redux] React Todo List Example (Toggling a Todo)
2016-01-12 [Redux] React Todo List Example (Adding a Todo)
2016-01-12 [React Testing] Redux Reducers
2015-01-12 [Node.js] Creating Demo APIs with json-server
点击右上角即可分享
微信分享提示