zoukankan      html  css  js  c++  java
  • [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
    */
  • 相关阅读:
    Js Array 删除
    语音播报功能
    js实现HashTable
    Js 克隆
    获取电脑名和IP地址
    获取电脑名和Ip
    IIS 配置问题
    WCF 服务
    【并查集】wikioi1001舒适的路线
    【实用】读取信息
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6277533.html
Copyright © 2011-2022 走看看