commit 12068606e032b9f9dc6a2c061a8c73d9076a9766 parent 5ec1c3591df84b9fe6524f261039cd1146814992 Author: Robin Bron <finwo@pm.me> Date: Fri, 10 Dec 2021 11:36:26 +0100 Removed readme.html, it was a debug file Diffstat:
| D | README.html | | | 38 | -------------------------------------- |
1 file changed, 0 insertions(+), 38 deletions(-)
diff --git a/README.html b/README.html @@ -1,38 +0,0 @@ -<h1>plimit</h1> -<p>Simple promise concurrency limiter</p> -<h2>Installation</h2> -<pre><code class="language-sh">npm install --save plimit -</code></pre> -<pre><code class="language-js"># node -import { plimit } from 'plimit'; -</code></pre> -<pre><code class="language-html"><!-- browser --> -<script src="/path/to/plimit/index.js"></script> -<script> - // use window.plimit -</script> -</code></pre> -<h2>Usage</h2> -<p>The package assumes native promises are available</p> -<p>This example shows iterating over accounts without loading all into memory</p> -<pre><code class="language-js">import { MoreThan } from 'typeorm'; -import { Account } from './model/account'; // typescript model - -const runner = plimit(4); // runner that allows 4 concurrent tasks -let accountId = ''; - -while(true) { - const account = await Account.findOne({ uuid: MoreThan(accountId) }); - if (!account) break; - accountId = account.uuid; - - // resolves instantly it's queue is not full - // waits for a previous task if it's queue is full - await runner.push(async () => { - // some lengthy process on the account - }); -} - -// Process remainder -await runner.flush(); -</code></pre>