Skip to content

Commit 8e032ab

Browse files
committed
publish 1.0.1 with new readme
1 parent 41a4e78 commit 8e032ab

File tree

9 files changed

+97
-45
lines changed

9 files changed

+97
-45
lines changed

coverage/clover.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1548089477303" clover="3.2.0">
3-
<project timestamp="1548089477304" name="All files">
2+
<coverage generated="1548321608364" clover="3.2.0">
3+
<project timestamp="1548321608364" name="All files">
44
<metrics statements="27" coveredstatements="27" conditionals="14" coveredconditionals="13" methods="11" coveredmethods="11" elements="52" coveredelements="51" complexity="0" loc="27" ncloc="27" packages="1" files="2" classes="2">
55
<file name="async-parallel-foreach.ts" path="/Users/donald/Project/async-parallel-foreach/src/async-parallel-foreach.ts">
66
<metrics statements="26" coveredstatements="26" conditionals="14" coveredconditionals="13" methods="11" coveredmethods="11"/>

coverage/lcov-report/async-parallel-foreach.ts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ <h1>
220220
</div><!-- /wrapper -->
221221
<div class='footer quiet pad2 space-top1 center small'>
222222
Code coverage
223-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Tue Jan 22 2019 00:51:17 GMT+0800 (Hong Kong Standard Time)
223+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Jan 24 2019 17:20:08 GMT+0800 (Hong Kong Standard Time)
224224
</div>
225225
</div>
226226
<script src="prettify.js"></script>

coverage/lcov-report/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h1>
9090
</div><!-- /wrapper -->
9191
<div class='footer quiet pad2 space-top1 center small'>
9292
Code coverage
93-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Tue Jan 22 2019 00:51:17 GMT+0800 (Hong Kong Standard Time)
93+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Jan 24 2019 17:20:08 GMT+0800 (Hong Kong Standard Time)
9494
</div>
9595
</div>
9696
<script src="prettify.js"></script>

coverage/lcov-report/index.ts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h1>
4949
</div><!-- /wrapper -->
5050
<div class='footer quiet pad2 space-top1 center small'>
5151
Code coverage
52-
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Tue Jan 22 2019 00:51:17 GMT+0800 (Hong Kong Standard Time)
52+
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Jan 24 2019 17:20:08 GMT+0800 (Hong Kong Standard Time)
5353
</div>
5454
</div>
5555
<script src="prettify.js"></script>

docs/globals.html

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -919,43 +919,55 @@
919919
<div class="tsd-panel tsd-typography">
920920
<h1 id="async-parallel-foreach">Async parallel forEach</h1>
921921
<p><a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="https://img.shields.io/npm/v/async-parallel-foreach.svg" alt="npm"></a>
922-
<a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="./coverage/badge.svg" alt="npm"></a>
923-
<a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="https://img.shields.io/npm/l/async-parallel-foreach.svg" alt="npm"></a></p>
924-
<p>Javascript module to perform <strong><em>async flow control</em></strong> on collection/iterable/dictionary <strong><em>in parallel</em></strong> and make <strong><em>retry easily</em></strong> when error occurred</p>
922+
<a href="https://github.com/Donaldcwl/async-parallel-foreach"><img src="./coverage/badge.svg" alt="npm"></a>
923+
<a href="https://github.com/Donaldcwl/async-parallel-foreach"><img src="https://img.shields.io/npm/l/async-parallel-foreach.svg" alt="npm"></a></p>
924+
<p>Javascript module to perform <strong><em>async flow control</em></strong> on collection/iterable/dictionary <strong><em>in controlled parallel</em></strong> and make <strong><em>retry easily</em></strong> when error occurred</p>
925+
<h2 id="features">Features</h2>
926+
<ul>
927+
<li>iterate collection (array/object/iterator) and <strong><em>run async function on each item</em></strong> in a collection</li>
928+
<li>control the <strong><em>concurrency</em></strong> of running async function on the items</li>
929+
<li><strong><em>auto retry</em></strong> when error occurred</li>
930+
<li><strong><em>delayed retry</em></strong></li>
931+
</ul>
925932
<h2 id="install">Install</h2>
926-
<pre><code>npm install <span class="hljs-keyword">async</span>-<span class="hljs-keyword">parallel</span>-foreach --save
927-
<span class="hljs-keyword">or</span>
928-
yarn <span class="hljs-keyword">add</span> <span class="hljs-keyword">async</span>-<span class="hljs-keyword">parallel</span>-foreach</code></pre><h2 id="how-to-use-this-module-in-your-project-">How to use this module in your project?</h2>
933+
<pre><code class="language-bash">npm install async-parallel-foreach async --save
934+
or
935+
yarn add async-parallel-foreach async</code></pre>
936+
<h2 id="how-to-use-this-module-in-your-project-">How to use this module in your project?</h2>
929937
<p>Frontend: used in framework like React, Angular, Vue etc
930938
(work with bundler like webpack and rollup)</p>
931-
<p>Backend: node.js</p>
932939
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { asyncParallelForEach, BACK_OFF_RETRY } <span class="hljs-keyword">from</span> <span class="hljs-string">'async-parallel-foreach'</span></code></pre>
940+
<p>Backend: node.js</p>
941+
<pre><code class="language-javascript"><span class="hljs-keyword">const</span> { asyncParallelForEach, BACK_OFF_RETRY } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'async-parallel-foreach'</span>)</code></pre>
933942
<h2 id="api">API</h2>
934943
<h3 id="main-function">Main function</h3>
935944
<h4 id="asyncparallelforeach-coll-collection-parallellimit-number-iteratee-function-eachmaxtry-promise-array-value-any-error-error-">asyncParallelForEach(coll: Collection, parallelLimit: number, iteratee: Function, eachMaxTry): Promise<Array&lt;{ value: any, error: Error }&gt;&gt;</h4>
936945
<ul>
937946
<li>coll - can be Array, Object (dictionary), Iterable</li>
938-
<li>parallelLimit - number of iteratee functions to be executed in parallel at any time</li>
939-
<li>iteratee - the function that you define to process each item in &quot;coll&quot;</li>
947+
<li>parallelLimit - number of iteratee functions to be executed in parallel at any time, set <code>parallelLimit = -1</code> for unlimited parallelization (all items will start process at once)</li>
948+
<li>iteratee - the function that you define to process each item in &quot;coll&quot;<ul>
949+
<li>if &quot;coll&quot; is array, it will call with (value, index) </li>
950+
<li>if &quot;coll&quot; is object, it will call with (value, key)</li>
951+
</ul>
952+
</li>
940953
<li>eachMaxTry - maximum number of times each item will be processed by &quot;iteratee&quot;.<ul>
941-
<li>if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function</li>
954+
<li>if <code>eachMaxTry = 2</code>, then the item will be retried 1 time when there is error throwed in the iteratee function</li>
942955
<li>add delay before retry<ul>
943-
<li>set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry</li>
956+
<li>set <code>eachMaxTry = { times: 2, interval: 1000 }</code> // wait for 1000 ms before retry</li>
944957
<li>interval can also accept function returning the interval in ms<ul>
945-
<li>e.g. eachMaxTry = { times: 2, interval: (retryCount) =&gt; retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial</li>
958+
<li>e.g. <code>eachMaxTry = { times: 2, interval: (retryCount) =&gt; retryCount * 1000 }</code> // retryCount start from 2 which means it is the 2nd trial<h3 id="back_off_retry-strategies">BACK_OFF_RETRY strategies</h3>
959+
</li>
946960
</ul>
947961
</li>
948962
</ul>
949963
</li>
950-
<li>eachMaxTry follows the &quot;opts&quot; argument in <a href="https://caolan.github.io/async/docs.html#retry">https://caolan.github.io/async/docs.html#retry</a> &quot;retry&quot; <h3 id="back_off_retry-strategies">BACK_OFF_RETRY strategies</h3>
951-
</li>
952964
</ul>
953965
</li>
954966
<li>predefined interval function you may use<h4 id="back_off_retry-randombetween-minms-number-maxms-number-">BACK_OFF_RETRY.randomBetween(minMs: number, maxMs: number)</h4>
955-
<h4 id="back_off_retry-exponential-">BACK_OFF_RETRY.exponential()</h4>
967+
</li>
968+
<li>e.g. <code>eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) }</code> // random delay between 100ms and 3000ms<h4 id="back_off_retry-exponential-">BACK_OFF_RETRY.exponential()</h4>
956969
</li>
957970
<li>start from 100ms, then 200ms, 400ms, 800ms, 1600ms, ...</li>
958-
<li>e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms</li>
959971
</ul>
960972
<p>(<a href="http://htmlpreview.github.io/?https://github.com/Donaldcwl/async-parallel-foreach/blob/master/docs/index.html">details api document in here</a>)</p>
961973
<h2 id="usage">Usage</h2>
@@ -1026,7 +1038,21 @@ <h2 id="usage">Usage</h2>
10261038
// }
10271039

10281040
<span class="hljs-keyword">return</span> results
1029-
}</code></pre>
1041+
}</code></pre><h2 id="example">Example</h2>
1042+
<p>Please check the &quot;example&quot; folder in this repo</p>
1043+
<ul>
1044+
<li>How to run the example:<pre><code class="language-bash">git <span class="hljs-built_in">clone</span> https://github.com/Donaldcwl/async-parallel-foreach.git
1045+
<span class="hljs-built_in">cd</span> async-parallel-foreach/example
1046+
yarn install <span class="hljs-comment"># or npm install</span>
1047+
node example.js</code></pre>
1048+
</li>
1049+
</ul>
1050+
<h3 id="todo-features">TODO FEATURES</h3>
1051+
<ul>
1052+
<li>get current status in the iteratee function e.g. currentTrial, isFirstTrial, isLastTrial, timeElapsed, failedReasons, incrementMaxTry</li>
1053+
<li>eachTrialTimeout, eachItemTimeout</li>
1054+
<li>run iteratee function in web worker for CPU intensive tasks (use tiny-worker for node.js)</li>
1055+
</ul>
10301056
</div>
10311057
<section class="tsd-panel-group tsd-index-group">
10321058
<h2>Index</h2>
@@ -1059,7 +1085,7 @@ <h3>async<wbr>Parallel<wbr>For<wbr>Each</h3>
10591085
<li class="tsd-description">
10601086
<aside class="tsd-sources">
10611087
<ul>
1062-
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/358bd6c/src/async-parallel-foreach.ts#L3">async-parallel-foreach.ts:3</a></li>
1088+
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/41a4e78/src/async-parallel-foreach.ts#L3">async-parallel-foreach.ts:3</a></li>
10631089
</ul>
10641090
</aside>
10651091
<h4 class="tsd-type-parameters-title">Type parameters</h4>

docs/index.html

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -919,43 +919,55 @@
919919
<div class="tsd-panel tsd-typography">
920920
<h1 id="async-parallel-foreach">Async parallel forEach</h1>
921921
<p><a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="https://img.shields.io/npm/v/async-parallel-foreach.svg" alt="npm"></a>
922-
<a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="./coverage/badge.svg" alt="npm"></a>
923-
<a href="https://www.npmjs.com/package/async-parallel-foreach"><img src="https://img.shields.io/npm/l/async-parallel-foreach.svg" alt="npm"></a></p>
924-
<p>Javascript module to perform <strong><em>async flow control</em></strong> on collection/iterable/dictionary <strong><em>in parallel</em></strong> and make <strong><em>retry easily</em></strong> when error occurred</p>
922+
<a href="https://github.com/Donaldcwl/async-parallel-foreach"><img src="./coverage/badge.svg" alt="npm"></a>
923+
<a href="https://github.com/Donaldcwl/async-parallel-foreach"><img src="https://img.shields.io/npm/l/async-parallel-foreach.svg" alt="npm"></a></p>
924+
<p>Javascript module to perform <strong><em>async flow control</em></strong> on collection/iterable/dictionary <strong><em>in controlled parallel</em></strong> and make <strong><em>retry easily</em></strong> when error occurred</p>
925+
<h2 id="features">Features</h2>
926+
<ul>
927+
<li>iterate collection (array/object/iterator) and <strong><em>run async function on each item</em></strong> in a collection</li>
928+
<li>control the <strong><em>concurrency</em></strong> of running async function on the items</li>
929+
<li><strong><em>auto retry</em></strong> when error occurred</li>
930+
<li><strong><em>delayed retry</em></strong></li>
931+
</ul>
925932
<h2 id="install">Install</h2>
926-
<pre><code>npm install <span class="hljs-keyword">async</span>-<span class="hljs-keyword">parallel</span>-foreach --save
927-
<span class="hljs-keyword">or</span>
928-
yarn <span class="hljs-keyword">add</span> <span class="hljs-keyword">async</span>-<span class="hljs-keyword">parallel</span>-foreach</code></pre><h2 id="how-to-use-this-module-in-your-project-">How to use this module in your project?</h2>
933+
<pre><code class="language-bash">npm install async-parallel-foreach async --save
934+
or
935+
yarn add async-parallel-foreach async</code></pre>
936+
<h2 id="how-to-use-this-module-in-your-project-">How to use this module in your project?</h2>
929937
<p>Frontend: used in framework like React, Angular, Vue etc
930938
(work with bundler like webpack and rollup)</p>
931-
<p>Backend: node.js</p>
932939
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { asyncParallelForEach, BACK_OFF_RETRY } <span class="hljs-keyword">from</span> <span class="hljs-string">'async-parallel-foreach'</span></code></pre>
940+
<p>Backend: node.js</p>
941+
<pre><code class="language-javascript"><span class="hljs-keyword">const</span> { asyncParallelForEach, BACK_OFF_RETRY } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'async-parallel-foreach'</span>)</code></pre>
933942
<h2 id="api">API</h2>
934943
<h3 id="main-function">Main function</h3>
935944
<h4 id="asyncparallelforeach-coll-collection-parallellimit-number-iteratee-function-eachmaxtry-promise-array-value-any-error-error-">asyncParallelForEach(coll: Collection, parallelLimit: number, iteratee: Function, eachMaxTry): Promise<Array&lt;{ value: any, error: Error }&gt;&gt;</h4>
936945
<ul>
937946
<li>coll - can be Array, Object (dictionary), Iterable</li>
938-
<li>parallelLimit - number of iteratee functions to be executed in parallel at any time</li>
939-
<li>iteratee - the function that you define to process each item in &quot;coll&quot;</li>
947+
<li>parallelLimit - number of iteratee functions to be executed in parallel at any time, set <code>parallelLimit = -1</code> for unlimited parallelization (all items will start process at once)</li>
948+
<li>iteratee - the function that you define to process each item in &quot;coll&quot;<ul>
949+
<li>if &quot;coll&quot; is array, it will call with (value, index) </li>
950+
<li>if &quot;coll&quot; is object, it will call with (value, key)</li>
951+
</ul>
952+
</li>
940953
<li>eachMaxTry - maximum number of times each item will be processed by &quot;iteratee&quot;.<ul>
941-
<li>if eachMaxTry = 2, then the item will be retried 1 time when there is error throwed in the iteratee function</li>
954+
<li>if <code>eachMaxTry = 2</code>, then the item will be retried 1 time when there is error throwed in the iteratee function</li>
942955
<li>add delay before retry<ul>
943-
<li>set eachMaxTry = { times: 2, interval: 1000 } // wait for 1000 ms before retry</li>
956+
<li>set <code>eachMaxTry = { times: 2, interval: 1000 }</code> // wait for 1000 ms before retry</li>
944957
<li>interval can also accept function returning the interval in ms<ul>
945-
<li>e.g. eachMaxTry = { times: 2, interval: (retryCount) =&gt; retryCount * 1000 } // retryCount start from 2 which means it is the 2nd trial</li>
958+
<li>e.g. <code>eachMaxTry = { times: 2, interval: (retryCount) =&gt; retryCount * 1000 }</code> // retryCount start from 2 which means it is the 2nd trial<h3 id="back_off_retry-strategies">BACK_OFF_RETRY strategies</h3>
959+
</li>
946960
</ul>
947961
</li>
948962
</ul>
949963
</li>
950-
<li>eachMaxTry follows the &quot;opts&quot; argument in <a href="https://caolan.github.io/async/docs.html#retry">https://caolan.github.io/async/docs.html#retry</a> &quot;retry&quot; <h3 id="back_off_retry-strategies">BACK_OFF_RETRY strategies</h3>
951-
</li>
952964
</ul>
953965
</li>
954966
<li>predefined interval function you may use<h4 id="back_off_retry-randombetween-minms-number-maxms-number-">BACK_OFF_RETRY.randomBetween(minMs: number, maxMs: number)</h4>
955-
<h4 id="back_off_retry-exponential-">BACK_OFF_RETRY.exponential()</h4>
967+
</li>
968+
<li>e.g. <code>eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) }</code> // random delay between 100ms and 3000ms<h4 id="back_off_retry-exponential-">BACK_OFF_RETRY.exponential()</h4>
956969
</li>
957970
<li>start from 100ms, then 200ms, 400ms, 800ms, 1600ms, ...</li>
958-
<li>e.g. eachMaxTry = { times: 5, interval: BACK_OFF_RETRY.randomBetween(100, 3000) } // random delay between 100ms and 3000ms</li>
959971
</ul>
960972
<p>(<a href="http://htmlpreview.github.io/?https://github.com/Donaldcwl/async-parallel-foreach/blob/master/docs/index.html">details api document in here</a>)</p>
961973
<h2 id="usage">Usage</h2>
@@ -1026,7 +1038,21 @@ <h2 id="usage">Usage</h2>
10261038
// }
10271039

10281040
<span class="hljs-keyword">return</span> results
1029-
}</code></pre>
1041+
}</code></pre><h2 id="example">Example</h2>
1042+
<p>Please check the &quot;example&quot; folder in this repo</p>
1043+
<ul>
1044+
<li>How to run the example:<pre><code class="language-bash">git <span class="hljs-built_in">clone</span> https://github.com/Donaldcwl/async-parallel-foreach.git
1045+
<span class="hljs-built_in">cd</span> async-parallel-foreach/example
1046+
yarn install <span class="hljs-comment"># or npm install</span>
1047+
node example.js</code></pre>
1048+
</li>
1049+
</ul>
1050+
<h3 id="todo-features">TODO FEATURES</h3>
1051+
<ul>
1052+
<li>get current status in the iteratee function e.g. currentTrial, isFirstTrial, isLastTrial, timeElapsed, failedReasons, incrementMaxTry</li>
1053+
<li>eachTrialTimeout, eachItemTimeout</li>
1054+
<li>run iteratee function in web worker for CPU intensive tasks (use tiny-worker for node.js)</li>
1055+
</ul>
10301056
</div>
10311057
<div style="position:relative;"><a name="typedoc-main-index" class="tsd-anchor"></a></div>
10321058
<section class="tsd-panel-group tsd-index-group">
@@ -1060,7 +1086,7 @@ <h3>async<wbr>Parallel<wbr>For<wbr>Each</h3>
10601086
<li class="tsd-description">
10611087
<aside class="tsd-sources">
10621088
<ul>
1063-
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/358bd6c/src/async-parallel-foreach.ts#L3">async-parallel-foreach.ts:3</a></li>
1089+
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/41a4e78/src/async-parallel-foreach.ts#L3">async-parallel-foreach.ts:3</a></li>
10641090
</ul>
10651091
</aside>
10661092
<h4 class="tsd-type-parameters-title">Type parameters</h4>

docs/modules/back_off_retry.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ <h3>exponential</h3>
945945
<li class="tsd-description">
946946
<aside class="tsd-sources">
947947
<ul>
948-
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/358bd6c/src/async-parallel-foreach.ts#L52">async-parallel-foreach.ts:52</a></li>
948+
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/41a4e78/src/async-parallel-foreach.ts#L52">async-parallel-foreach.ts:52</a></li>
949949
</ul>
950950
</aside>
951951
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">exponentialBackoff</span></h4>
@@ -962,7 +962,7 @@ <h3>random<wbr>Between</h3>
962962
<li class="tsd-description">
963963
<aside class="tsd-sources">
964964
<ul>
965-
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/358bd6c/src/async-parallel-foreach.ts#L46">async-parallel-foreach.ts:46</a></li>
965+
<li>Defined in <a href="https://github.com/Donaldcwl/async-parallel-foreach/blob/41a4e78/src/async-parallel-foreach.ts#L46">async-parallel-foreach.ts:46</a></li>
966966
</ul>
967967
</aside>
968968
<h4 class="tsd-parameters-title">Parameters</h4>

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
transform: {
3-
'.(ts|tsx)': '<rootDir>/node_modules/ts-jest/preprocessor.js'
3+
'.(ts|tsx)': 'ts-jest'
44
},
55
testEnvironment: 'node',
66
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "async-parallel-foreach",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "dist/index.umd.js",
55
"module": "dist/index.es.js",
66
"types": "dist/types/index.d.ts",

0 commit comments

Comments
 (0)