推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
benb

要不 promisify 一下原生数组?

  •  
  •   benb · Jan 4, 2021 · 2581 views
    This topic created in 1955 days ago, the information mentioned may be changed or developed.

    这样 map 、filter 、reduce 这些方法也可以传递 async 函数了……

    import Prray from 'prray'
    
    // 1) create
    const urls = Prray.from(['www.google.com', 'npmjs.org'])
    
    
    // 2) async method
    const responses = await urls.mapAsync(fetch)
    
    
    // 3) method chaining with both normal and async methods
    await urls
      .concat(['github.com', 'wikipedia.org'])
      .mapAsync(request)
      .filter(isValidHtml)
      .forEachAsync(saveToDB)
    
    
    // 4) concurrency limit
    const responses = await urls.mapAsync(fetch, { concurrency: 10 })
    

    工具包的文档和路径: https://github.com/Bin-Huang/prray

    2 replies    2021-01-04 18:24:39 +08:00
    gouflv
        1
    gouflv  
       Jan 4, 2021 via iPhone
    看到了 rxjs 的影子
    xiaoming1992
        2
    xiaoming1992  
       Jan 4, 2021 via Android
    粗略瞄了一眼,挺有意思的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1061 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 18:42 · PVG 02:42 · LAX 11:42 · JFK 14:42
    ♥ Do have faith in what you're doing.