From 8e032ab1814a6233a3e1659b17b5e6b5117f4bc2 Mon Sep 17 00:00:00 2001 From: Donald Date: Sat, 26 Jan 2019 10:18:11 +0800 Subject: [PATCH] publish 1.0.1 with new readme --- coverage/clover.xml | 4 +- .../async-parallel-foreach.ts.html | 2 +- coverage/lcov-report/index.html | 2 +- coverage/lcov-report/index.ts.html | 2 +- docs/globals.html | 62 +++++++++++++------ docs/index.html | 62 +++++++++++++------ docs/modules/back_off_retry.html | 4 +- jest.config.js | 2 +- package.json | 2 +- 9 files changed, 97 insertions(+), 45 deletions(-) diff --git a/coverage/clover.xml b/coverage/clover.xml index a99c406..aa6970c 100644 --- a/coverage/clover.xml +++ b/coverage/clover.xml @@ -1,6 +1,6 @@ - - + + diff --git a/coverage/lcov-report/async-parallel-foreach.ts.html b/coverage/lcov-report/async-parallel-foreach.ts.html index fbac3a3..3fc3733 100644 --- a/coverage/lcov-report/async-parallel-foreach.ts.html +++ b/coverage/lcov-report/async-parallel-foreach.ts.html @@ -220,7 +220,7 @@

diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html index f2636c7..769c3bb 100644 --- a/coverage/lcov-report/index.html +++ b/coverage/lcov-report/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/lcov-report/index.ts.html b/coverage/lcov-report/index.ts.html index 8185deb..4b3ef91 100644 --- a/coverage/lcov-report/index.ts.html +++ b/coverage/lcov-report/index.ts.html @@ -49,7 +49,7 @@

diff --git a/docs/globals.html b/docs/globals.html index 3659624..2f5b073 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -919,43 +919,55 @@

Async parallel forEach

npm - npm - npm

-

Javascript module to perform async flow control on collection/iterable/dictionary in parallel and make retry easily when error occurred

+ npm + npm

+

Javascript module to perform async flow control on collection/iterable/dictionary in controlled parallel and make retry easily when error occurred

+

Features

+
    +
  • iterate collection (array/object/iterator) and run async function on each item in a collection
  • +
  • control the concurrency of running async function on the items
  • +
  • auto retry when error occurred
  • +
  • delayed retry
  • +

Install

-
npm install async-parallel-foreach --save
-or
-yarn add async-parallel-foreach

How to use this module in your project?

+
npm install async-parallel-foreach async --save
+or
+yarn add async-parallel-foreach async
+

How to use this module in your project?

Frontend: used in framework like React, Angular, Vue etc (work with bundler like webpack and rollup)

-

Backend: node.js

import { asyncParallelForEach, BACK_OFF_RETRY } from 'async-parallel-foreach'
+

Backend: node.js

+
const { asyncParallelForEach, BACK_OFF_RETRY } = require('async-parallel-foreach')

API

Main function

asyncParallelForEach(coll: Collection, parallelLimit: number, iteratee: Function, eachMaxTry): Promise
  • coll - can be Array, Object (dictionary), Iterable
  • -
  • parallelLimit - number of iteratee functions to be executed in parallel at any time
  • -
  • iteratee - the function that you define to process each item in "coll"
  • +
  • parallelLimit - number of iteratee functions to be executed in parallel at any time, set parallelLimit = -1 for unlimited parallelization (all items will start process at once)
  • +
  • iteratee - the function that you define to process each item in "coll"
      +
    • if "coll" is array, it will call with (value, index)
    • +
    • if "coll" is object, it will call with (value, key)
    • +
    +
  • eachMaxTry - maximum number of times each item will be processed by "iteratee".
      -
    • if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function
    • +
    • if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function
    • add delay before retry
        -
      • set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry
      • +
      • set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry
      • interval can also accept function returning the interval in ms
          -
        • e.g. eachMaxTry = { times: 2, interval: (retryCount) => retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial
        • +
        • e.g. eachMaxTry = { times: 2, interval: (retryCount) => retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial

          BACK_OFF_RETRY strategies

          +
    • -
    • eachMaxTry follows the "opts" argument in https://caolan.github.io/async/docs.html#retry "retry"

      BACK_OFF_RETRY strategies

      -
  • predefined interval function you may use

    BACK_OFF_RETRY.randomBetween(minMs: number, maxMs: number)

    -

    BACK_OFF_RETRY.exponential()

    +
  • +
  • e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms

    BACK_OFF_RETRY.exponential()

  • start from 100ms, then 200ms, 400ms, 800ms, 1600ms, ...
  • -
  • e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms

(details api document in here)

Usage

@@ -1026,7 +1038,21 @@

Usage

// } return results -} +}

Example

+

Please check the "example" folder in this repo

+
    +
  • How to run the example:
    git clone https://github.com/Donaldcwl/async-parallel-foreach.git
    +cd async-parallel-foreach/example
    +yarn install # or npm install
    +node example.js
    +
  • +
+

TODO FEATURES

+
    +
  • get current status in the iteratee function e.g. currentTrial, isFirstTrial, isLastTrial, timeElapsed, failedReasons, incrementMaxTry
  • +
  • eachTrialTimeout, eachItemTimeout
  • +
  • run iteratee function in web worker for CPU intensive tasks (use tiny-worker for node.js)
  • +

Index

@@ -1059,7 +1085,7 @@

asyncParallelForEach

  • Type parameters

    diff --git a/docs/index.html b/docs/index.html index 0f8befe..b10a451 100644 --- a/docs/index.html +++ b/docs/index.html @@ -919,43 +919,55 @@

    Async parallel forEach

    npm - npm - npm

    -

    Javascript module to perform async flow control on collection/iterable/dictionary in parallel and make retry easily when error occurred

    + npm + npm

    +

    Javascript module to perform async flow control on collection/iterable/dictionary in controlled parallel and make retry easily when error occurred

    +

    Features

    +
      +
    • iterate collection (array/object/iterator) and run async function on each item in a collection
    • +
    • control the concurrency of running async function on the items
    • +
    • auto retry when error occurred
    • +
    • delayed retry
    • +

    Install

    -
    npm install async-parallel-foreach --save
    -or
    -yarn add async-parallel-foreach

    How to use this module in your project?

    +
    npm install async-parallel-foreach async --save
    +or
    +yarn add async-parallel-foreach async
    +

    How to use this module in your project?

    Frontend: used in framework like React, Angular, Vue etc (work with bundler like webpack and rollup)

    -

    Backend: node.js

    import { asyncParallelForEach, BACK_OFF_RETRY } from 'async-parallel-foreach'
    +

    Backend: node.js

    +
    const { asyncParallelForEach, BACK_OFF_RETRY } = require('async-parallel-foreach')

    API

    Main function

    asyncParallelForEach(coll: Collection, parallelLimit: number, iteratee: Function, eachMaxTry): Promise
    • coll - can be Array, Object (dictionary), Iterable
    • -
    • parallelLimit - number of iteratee functions to be executed in parallel at any time
    • -
    • iteratee - the function that you define to process each item in "coll"
    • +
    • parallelLimit - number of iteratee functions to be executed in parallel at any time, set parallelLimit = -1 for unlimited parallelization (all items will start process at once)
    • +
    • iteratee - the function that you define to process each item in "coll"
        +
      • if "coll" is array, it will call with (value, index)
      • +
      • if "coll" is object, it will call with (value, key)
      • +
      +
    • eachMaxTry - maximum number of times each item will be processed by "iteratee".
        -
      • if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function
      • +
      • if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function
      • add delay before retry
          -
        • set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry
        • +
        • set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry
        • interval can also accept function returning the interval in ms
            -
          • e.g. eachMaxTry = { times: 2, interval: (retryCount) => retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial
          • +
          • e.g. eachMaxTry = { times: 2, interval: (retryCount) => retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial

            BACK_OFF_RETRY strategies

            +
      • -
      • eachMaxTry follows the "opts" argument in https://caolan.github.io/async/docs.html#retry "retry"

        BACK_OFF_RETRY strategies

        -
    • predefined interval function you may use

      BACK_OFF_RETRY.randomBetween(minMs: number, maxMs: number)

      -

      BACK_OFF_RETRY.exponential()

      +
    • +
    • e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms

      BACK_OFF_RETRY.exponential()

    • start from 100ms, then 200ms, 400ms, 800ms, 1600ms, ...
    • -
    • e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms

    (details api document in here)

    Usage

    @@ -1026,7 +1038,21 @@

    Usage

    // } return results -} +}

    Example

    +

    Please check the "example" folder in this repo

    +
      +
    • How to run the example:
      git clone https://github.com/Donaldcwl/async-parallel-foreach.git
      +cd async-parallel-foreach/example
      +yarn install # or npm install
      +node example.js
      +
    • +
    +

    TODO FEATURES

    +
      +
    • get current status in the iteratee function e.g. currentTrial, isFirstTrial, isLastTrial, timeElapsed, failedReasons, incrementMaxTry
    • +
    • eachTrialTimeout, eachItemTimeout
    • +
    • run iteratee function in web worker for CPU intensive tasks (use tiny-worker for node.js)
    • +

    @@ -1060,7 +1086,7 @@

    asyncParallelForEach

  • Type parameters

    diff --git a/docs/modules/back_off_retry.html b/docs/modules/back_off_retry.html index 3f36a61..b1b0e15 100644 --- a/docs/modules/back_off_retry.html +++ b/docs/modules/back_off_retry.html @@ -945,7 +945,7 @@

    exponential

  • Returns exponentialBackoff

    @@ -962,7 +962,7 @@

    randomBetween

  • Parameters

    diff --git a/jest.config.js b/jest.config.js index ce659d3..c0d45d1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,6 @@ module.exports = { transform: { - '.(ts|tsx)': '/node_modules/ts-jest/preprocessor.js' + '.(ts|tsx)': 'ts-jest' }, testEnvironment: 'node', testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$', diff --git a/package.json b/package.json index e732764..3875ec1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "async-parallel-foreach", - "version": "1.0.0", + "version": "1.0.1", "main": "dist/index.umd.js", "module": "dist/index.es.js", "types": "dist/types/index.d.ts",