项目作者: csvwolf

项目描述 :
execute a promise array without sequence and status
高级语言: JavaScript
项目地址: git://github.com/csvwolf/promise-foreach.git
创建时间: 2018-08-28T12:39:27Z
项目社区:https://github.com/csvwolf/promise-foreach

开源协议:MIT License

下载


promise-foreach

Introduce

  • Promise.all: one failed, all failed
  • Promise.race: one fulfilled, all fulfilled
  • Promise.each: handle one by one

Well, if I want to run the promises at the same time… and, statistics the percent of success?

Promise foreach can! It will never throw a reject, you can handle the result with one success handler and one error handler.

Install

  1. npm install sky-promise-foreach

Usage

  1. const foreach = require('sky-promise-foreach')
  2. foreach([...promises], (result) => {
  3. // success handler for each promise
  4. }, (err) => {
  5. // error handler for each promise
  6. })