{"_id":"cwait","_rev":"11-23f82c3bdcbe9a129812c1fe90450fdd","name":"cwait","description":"Limit number of promises running in parallel","dist-tags":{"latest":"1.1.2"},"versions":{"0.0.1":{"name":"cwait","version":"0.0.1","description":"Limit number of promises running in parallel","main":"dist/cwait.js","typings":"dist/cwait.d.ts","scripts":{"tsc":"tsc","docts":"docts","prepublish":"tsc","test":"npm link cwait && tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","devDependencies":{"bluebird":"^3.3.3","docts":"0.0.3","typescript":"^1.8.7"},"gitHead":"590b6e33f856129885c9655bb1facd22df5806a4","_id":"cwait@0.0.1","_shasum":"aa0df5833c3b35d7b01ee310a591612ab9bb196b","_from":".","_npmVersion":"3.7.5","_nodeVersion":"4.2.4","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"shasum":"aa0df5833c3b35d7b01ee310a591612ab9bb196b","tarball":"https://registry.npmjs.org/cwait/-/cwait-0.0.1.tgz","integrity":"sha512-Fa/JuKjbfo3s/OoTpifdIr+NtdEquKoFYDTkusHsghUEy6KHi8pambxuanVGxGhsVFKm+I+MqlINldnhDhQr/g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEcPYnXWZxFe5UjPI9NxgGPF04W6DRcDZOdSx1ewY95IAiBt5ew1QkkZO3RiyFPlD42HRjbI5CSPgbcQhQaZgbKoVA=="}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/cwait-0.0.1.tgz_1459354098447_0.4925392596051097"},"directories":{}},"0.0.2":{"name":"cwait","version":"0.0.2","description":"Limit number of promises running in parallel","main":"dist/cwait.js","typings":"dist/cwait.d.ts","scripts":{"tsc":"tsc","docts":"docts","prepublish":"tsc","test":"npm link cwait && tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","devDependencies":{"bluebird":"^3.3.3","docts":"0.0.3","typescript":"^1.8.7"},"gitHead":"99c8608d9e0e2b43d346ca550f7525eca223bece","_id":"cwait@0.0.2","_shasum":"726bcc9a9d53a32095489dc2af1a6aadf7b33853","_from":".","_npmVersion":"3.7.5","_nodeVersion":"4.2.4","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"shasum":"726bcc9a9d53a32095489dc2af1a6aadf7b33853","tarball":"https://registry.npmjs.org/cwait/-/cwait-0.0.2.tgz","integrity":"sha512-eWMIi6DfawcGPAb2w2+MLqi6/CbypDJN03KjC5jeJCQJcCycIojectfmRXhWpqeYhsAJYh0QEvzU9CTvds8z2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCx91Qrf1uPxXTvZJ3sl07ZeAL/9i27nvhye+qmxid5zgIhAK/L/48djiJ5bOpcc1iVfXYml9hMD/V8kyyUuW5NnSTX"}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/cwait-0.0.2.tgz_1459617975672_0.17261752602644265"},"directories":{}},"0.0.3":{"name":"cwait","version":"0.0.3","description":"Limit number of promises running in parallel","main":"dist/cwait.js","typings":"dist/cwait.d.ts","scripts":{"tsc":"tsc","docts":"docts","prepublish":"tsc","test":"npm link cwait && tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","devDependencies":{"bluebird":"^3.3.5","docts":"~0.0.4","typescript":"^1.8.10"},"gitHead":"21c6fef323ce7b026e59278cfc192fdee94eb85e","_id":"cwait@0.0.3","_shasum":"8edbbafe72cab800e65848ab015b2ac685aac33e","_from":".","_npmVersion":"3.8.6","_nodeVersion":"6.0.0","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"shasum":"8edbbafe72cab800e65848ab015b2ac685aac33e","tarball":"https://registry.npmjs.org/cwait/-/cwait-0.0.3.tgz","integrity":"sha512-x5jh/qmREZ9BEIKMQME7cOMuoM+yviMpIYX5A+aKO4SGi1P3EKgelMJQL4Vzu1+mIKmMTZgxyq/416Q0N56BNA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDql9s2+1jdPgwjuLzdwSZYuPo1Qc113Pj6InpL4MlcYAIhAP6MSoAMCLAK9k6nVzwm8Y2au9bARp+USHkrHoWaoMNX"}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/cwait-0.0.3.tgz_1462372900695_0.7244007177650928"},"directories":{}},"1.0.0":{"name":"cwait","version":"1.0.0","description":"Limit number of promises running in parallel","main":"dist/cwait.js","typings":"dist/cwait.d.ts","scripts":{"tsc":"tsc","docts":"docts","prepublish":"tsc","test":"npm link cwait && tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","devDependencies":{"bluebird":"^3.3.5","docts":"~0.0.4","typescript":"^1.8.10"},"gitHead":"c0737d606fdaa9760876d77f538468089d891cce","_id":"cwait@1.0.0","_shasum":"e6c63dae4b5dd5408e4dec68af077804bf501538","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"shasum":"e6c63dae4b5dd5408e4dec68af077804bf501538","tarball":"https://registry.npmjs.org/cwait/-/cwait-1.0.0.tgz","integrity":"sha512-a3x7yZ1oANL1s7W6gYF0s+zoff7gQK6CNwS6mUyCyL/s4dr6X9gZcGNPABc146vTolcd/qtsJdBnIy4Tvt3ayw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHESUJ01mwVCxHOjQrQOHHXD6Birmy0/I4tTMQeU4u/pAiBWy6XIIiwfw6tfDWyPDpGdsMKP78TbZC6LtURSqbKGOA=="}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/cwait-1.0.0.tgz_1462887046714_0.4360006391070783"},"directories":{}},"1.0.1":{"name":"cwait","version":"1.0.1","description":"Limit number of promises running in parallel","main":"dist/cwait.js","typings":"dist/cwait.d.ts","scripts":{"tsc":"tsc","docts":"docts","tslint":"tslint","prepublish":"tslint -c src/tslint.json src/*.ts && tsc -p src","test":"tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","devDependencies":{"@types/bluebird":"^3.0.36","bluebird":"^3.4.6","docts":"~0.1.0","tslint":"^4.0.2","typescript":"^2.1.4"},"gitHead":"3a42734785908fb6994ac143f1228669ad3a199a","_id":"cwait@1.0.1","_shasum":"db258686e4632a5333bc230ccb4f738b2c41467b","_from":".","_npmVersion":"4.0.3","_nodeVersion":"7.0.0","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"shasum":"db258686e4632a5333bc230ccb4f738b2c41467b","tarball":"https://registry.npmjs.org/cwait/-/cwait-1.0.1.tgz","integrity":"sha512-KgjEOIxAbCd4bDdjkN/poaqlqy1+C97VB/2H/0YzWTaBM9ArVqBI2Ij3DDHQON8DD1rcoBreGVSzkvw1P+gnQw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHDobB3abFCFlpr2PLpGKIxnlF1ybzLAhQmhuROlUIVeAiEA7Ef77DKWo8mM7dq+G4YtB6dNXhZ4xxxbViL30/Sw0lY="}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/cwait-1.0.1.tgz_1481728036808_0.4009298700839281"},"directories":{}},"1.1.0":{"name":"cwait","version":"1.1.0","description":"Limit number of promises running in parallel","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"tsc":"tsc","docts":"docts","tslint":"tslint","lint":"node src/checkver.js lt 4.1.2 || tslint --type-check -c src/tslint.json -p src/tsconfig.json","prepublish":"npm run lint && tsc -p src","test":"tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","keywords":["promise","concurrent","concurrency","parallel","timeout","delay","wait","queue"],"devDependencies":{"@types/bluebird":"^3.5.8","@types/node":"^6.0.81","bluebird":"^3.5.0","tslint":"^5.5.0","typescript":"^2.4.1"},"dependencies":{"cdata":"^0.1.1"},"gitHead":"9779ef973243a9bc3752be2ad58075676d053b4c","_id":"cwait@1.1.0","_npmVersion":"5.0.3","_nodeVersion":"8.1.3","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"integrity":"sha512-3Lg4kzV8rKZBwU3RHcsojiCdccqPWHtu83uJ3E8++keR/1+Fye0XjrKZ34JWtiLp1LNgorMOdw27GShTBmwNiA==","shasum":"1f428ccb23401c1ddbda7c8c86fb005998f05c45","tarball":"https://registry.npmjs.org/cwait/-/cwait-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCebRWD4YyFqjc0/jpkGbNImun5NsGKl6SKkq2mjt73mwIhAKCihJJcAEn4Elcfdx6IbSAvA+eFkF9Z7FsvZY9zN0Cq"}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cwait-1.1.0.tgz_1499962367005_0.7857160633429885"},"directories":{}},"1.1.1":{"name":"cwait","version":"1.1.1","description":"Limit number of promises running in parallel","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"tsc":"tsc","docts":"docts","tslint":"tslint","lint":"node src/checkver.js lt 4.1.2 || tslint --type-check -c src/tslint.json -p src/tsconfig.json","prepublish":"npm run lint && tsc -p src","test":"tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","keywords":["promise","concurrent","concurrency","parallel","timeout","delay","wait","queue"],"devDependencies":{"@types/bluebird":"^3.5.8","@types/node":"^8.0.19","bluebird":"^3.5.0","tslint":"^5.5.0","typescript":"^2.4.2"},"dependencies":{"cdata":"^0.1.1"},"gitHead":"c40a899e9d09a861759507eedf709fb7ea82038f","_id":"cwait@1.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.2.1","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"integrity":"sha512-VRS0E6E41fK2QDYIGsVeE6FRXoH5Vf3hGtDL/jZxh3W+KPVVoEggDem5xJveihgZrd+xmYSqGPIUi/jv5zXcxQ==","shasum":"cebfe84274fa699cc49c0763c41f89d886177b10","tarball":"https://registry.npmjs.org/cwait/-/cwait-1.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA9r/Gsy2+n1bfkoJ4QIVo9OSQbgyW2sLujfh8RGPVVaAiB/XOo7YEoAvClpSQjxZ+uVllbeEnaPrn/sfIraoOyLsQ=="}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cwait-1.1.1.tgz_1501999023436_0.7249033923726529"},"directories":{}},"1.1.2":{"name":"cwait","version":"1.1.2","description":"Limit number of promises running in parallel","main":"dist/cjs/index.js","module":"dist/esm/index.js","browser":"dist/umd/index.js","typings":"dist/esm/index.d.ts","scripts":{"tsc":"tsc","rollup":"rollup","prepublish":"(checkver ge 5.0.0 && tsc -m es6 --outdir dist/esm -p src && rollup -c) || tsc -p src","test":"tsc -p test && node test/test.js"},"author":{"name":"Juha Järvi"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"homepage":"https://github.com/charto/cwait#readme","keywords":["promise","concurrent","concurrency","parallel","timeout","delay","wait","queue"],"devDependencies":{"@types/bluebird":"^3.5.24","@types/node":"^10.12.1","autoroll":"0.1.0","bluebird":"^3.5.2","rollup":"^0.66.6","typescript":"^3.1.4"},"dependencies":{"cdata":"^0.1.1"},"gitHead":"133120750ffeb98297dc46a2e490a7c98ce62de7","_id":"cwait@1.1.2","_npmVersion":"6.4.0","_nodeVersion":"8.2.1","_npmUser":{"name":"jjrv","email":"befunge@gmail.com"},"dist":{"integrity":"sha512-kIx8zE5jJ1iBgZytTr01aj57HdC+thPsg8W9Tw0gbf30/F7wfRRUS+BiXT90Dn+A0oGtF0xLT5293Ua4w/ZsNA==","shasum":"2a6a84fa7f1305486399df90feacb4f4a6719ca2","tarball":"https://registry.npmjs.org/cwait/-/cwait-1.1.2.tgz","fileCount":12,"unpackedSize":33710,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb4fo7CRA9TVsSAnZWagAA/awP/3A/kdZOMWtG52G2/Xb2\nnB/sINjrIotCr6uBmAcrKh/W3dfrSSkIylgiOhUq0pXDo2A77ujVRKoynWHD\nhQcTuuubVr05qEbm1hea0fUQ6DSPJOY096b3DcjF3G6Yd1nWqje0QO/WZBjv\n58esFKEGk/b5KiCbb1ftDhWqORNL8KWLlC/cFQHh2jsxEhIBoMLMlVusUGGo\nC02iBncr6Ac9Zd+efhqAum2bSQW2UFW5gHNo/Pt8tLqrXgKUQtZkiPDILOki\nuzR3EjMlBXoGnu4sV0OYFJ0WvW4BwTW0x23iXzgLMAJe1WQ0DBGq7wQKd3hD\ncWnXaHd2wYeCRsI+sPwLdtwMPTnM7o1HrjGwzvscCnFoc5T6PaxRigXuDNur\np/gHunKVntPbljtNFU6OCMAYTBHOP2N7Q1mR4TlxjXrGOD3XM+iM8uEKTJvi\nDqAJn4u9yas2QqxKalbOAOD86odd1rSHm75y/evIpaMrllHGn6M1UsRfH9Gq\naaAPqAMgyXMG3mqZjmY1WJWOsTcaF/3T/9bbk07laoOAzaJIOO6vVqmKvxXR\nVHYdQvNpD55pRWUiHcn1KHMjLBz0ADvchGwwNmqBCVSJ9uQ2pFqnR7zxk8WH\nsEL/8YiPiW0l+tgLM4DbhK/UnqxY/vu+jVPKqPWT6/auj1/9AsITA1bod8SP\nmsoA\r\n=Oyvk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAuCVUV9z2FzJHnWwkNdm1K64G56+0nWGc8KAS25qoDAIgDOvl2AQXbwtFieqivZQrmThX0M0tr6a8/Yl+261mNpQ="}]},"maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cwait_1.1.2_1541536314994_0.5340139751522686"},"_hasShrinkwrap":false}},"readme":"cwait\n=====\n\n[![build status](https://travis-ci.org/charto/cwait.svg?branch=master)](http://travis-ci.org/charto/cwait)\n[![npm monthly downloads](https://img.shields.io/npm/dm/cwait.svg)](https://www.npmjs.com/package/cwait)\n[![npm version](https://img.shields.io/npm/v/cwait.svg)](https://www.npmjs.com/package/cwait)\n\n`cwait` provides a queue handler ([`TaskQueue`](#api-TaskQueue)) and a wrapper ([`Task`](#api-Task)) for promises,\nto limit how many are being resolved simultaneously. It can wrap any ES6-compatible promises.\nThis allows for example limiting simultaneous downloads with minor changes to existing code.\nJust wrap your existing \"download finished\" promise and use it as before.\n\nThis is a tiny library with a single dependency, usable both in browsers and Node.js.\n\nUsage\n-----\n\nCreate a new `TaskQueue` passing it whatever `Promise` constructor you're using (ES6, Bluebird, some other shim...)\nand the maximum number of promise-returning functions to run concurrently.\nThen just call `queue.wrap(<function>)` instead of `<function>` to limit simultaneous execution.\n\nSimple Node.js example:\n\n```TypeScript\nimport * as Promise from 'bluebird';\nimport {TaskQueue} from 'cwait';\n\n/** Queue allowing 3 concurrent function calls. */\nvar queue = new TaskQueue(Promise, 3);\n\nPromise.map(list, download); // Download all listed files simultaneously.\n\nPromise.map(list, queue.wrap(download)); // Download 3 files at a time.\n```\n\nSee [`test/test.ts`](test/test.ts) for some runnable code or run it like this:\n\n```sh\ngit clone https://github.com/charto/cwait.git\ncd cwait\nnpm install\nnpm test\n```\n\nRecursion\n---------\n\nRecursive loops that run in parallel require special care.\nNested concurrency-limited calls (that are not tail-recursive) must be wrapped in `queue.unblock()`.\n\nHere's a simple example that fails:\n\n```JavaScript\nvar queue = new (require('cwait').TaskQueue)(Promise, 3);\n\nvar rec = queue.wrap(function(n) {\n    console.log(n);\n    return(n && Promise.resolve(rec(n - 1)));\n});\n\nrec(10);\n```\n\nIt only prints numbers 10, 9 and 8.\nMore calls don't get scheduled because there are already 3 promises pending.\nFor example Node.js exits immediately afterwards because the program is not blocked waiting for any system calls.\n\nPassing a promise to `queue.unblock(promise)` tells `queue` that\nthe current function will wait for `promise` to resolve before continuing.\nOne additional concurrent function is then allowed until the promise resolves.\n\nBe careful not to call `queue.unblock()` more than once (concurrently) from inside a wrapped function!\nOtherwise the queue may permit more simultaneous tasks than the intended limit.\n\nHere is a corrected example:\n\n```JavaScript\nvar queue = new (require('cwait').TaskQueue)(Promise, 3);\n\nvar rec = queue.wrap(function(n) {\n    console.log(n);\n    return(n && queue.unblock(Promise.resolve(rec(n - 1))));\n});\n\nrec(10);\n```\n\nAdvanced example with recursion\n-------------------------------\n\nThe following code recursively calculates the 10th Fibonacci number (55)\nrunning 3 recursive steps in parallel, each with an artificial 10-millisecond delay.\n\nAt the end, it prints the result (55) and the number of concurrent calls (3).\n\n```JavaScript\nvar queue = new (require('cwait').TaskQueue)(Promise, 3);\n\nvar maxRunning = 0;\nvar running = 0;\nvar delay = 10;\n\nvar fib = queue.wrap(function(n) {\n    // \"Calculation\" begins. Track maximum concurrent executions.\n    if(++running > maxRunning) maxRunning = running;\n\n    return(new Promise(function(resolve, reject) {\n        setTimeout(function() {\n            // \"Calculation\" ends.\n            --running;\n\n            // Each Fibonacci number is the sum of the previous two, except\n            // the first ones are 0, 1 (starting from the 0th number).\n            // Calculate them in parallel and unblock the queue until ready.\n\n            resolve(n < 2 ? n :\n                queue.unblock(Promise.all([\n                    fib(n - 1),\n                    fib(n - 2)\n                ])).then(function(r) {\n                    // Sum results from parallel recursion.\n                    return(r[0] + r[1]);\n                })\n            );\n        }, delay);\n    }));\n});\n\nfib(10).then(function(x) {\n    console.log('Result: ' + x);\n    console.log('Concurrency: ' + maxRunning);\n});\n```\n\nAPI\n===\nDocs generated using [`docts`](https://github.com/charto/docts)\n\n\n>\n> <a name=\"api-Task\"></a>\n> ### Class [`Task`](#api-Task)\n> <em>Task wraps a promise, delaying it until some resource gets less busy.</em>  \n> Source code: [`<>`](http://github.com/charto/cwait/blob/bcc3b2b/src/Task.ts#L49-L80)  \n>  \n> Methods:  \n> > **new( )** <sup>&rArr; <code>[Task](#api-Task)&lt;PromiseType&gt;</code></sup> [`<>`](http://github.com/charto/cwait/blob/bcc3b2b/src/Task.ts#L50-L53)  \n> > &emsp;&#x25aa; func <sup><code>() =&gt; PromiseType</code></sup>  \n> > &emsp;&#x25aa; Promise <sup><code>[PromisyClass](#api-PromisyClass)&lt;PromiseType&gt;</code></sup>  \n> > **.delay( )** <sup>&rArr; <code>PromiseType</code></sup> [`<>`](http://github.com/charto/cwait/blob/bcc3b2b/src/Task.ts#L57-L66)  \n> > &emsp;<em>Wrap task result in a new promise so it can be resolved later.</em>  \n> > **.resume( )** <sup>&rArr; <code>PromiseType</code></sup> [`<>`](http://github.com/charto/cwait/blob/bcc3b2b/src/Task.ts#L70-L72)  \n> > &emsp;<em>Start the task and call onFinish when done.</em>  \n> > &emsp;&#x25aa; onFinish <sup><code>() =&gt; void</code></sup>  \n>\n> <a name=\"api-TaskQueue\"></a>\n> ### Class [`TaskQueue`](#api-TaskQueue)\n> Source code: [`<>`](http://github.com/charto/cwait/blob/c57c0fd/src/TaskQueue.ts#L6-L75)  \n>  \n> Methods:  \n> > **new( )** <sup>&rArr; <code>[TaskQueue](#api-TaskQueue)&lt;PromiseType&gt;</code></sup> [`<>`](http://github.com/charto/cwait/blob/c57c0fd/src/TaskQueue.ts#L7-L11)  \n> > &emsp;&#x25aa; Promise <sup><code>[PromisyClass](#api-PromisyClass)&lt;PromiseType&gt;</code></sup>  \n> > &emsp;&#x25aa; concurrency <sup><code>number</code></sup>  \n> > **.add( )** <sup>&rArr; <code>PromiseType</code></sup> [`<>`](http://github.com/charto/cwait/blob/c57c0fd/src/TaskQueue.ts#L16-L33)  \n> > &emsp;<em>Add a new task to the queue.</em>  \n> > &emsp;<em>It will start when the number of other concurrent tasks is low enough.</em>  \n> > &emsp;&#x25aa; func <sup><code>() =&gt; PromiseType</code></sup>  \n> > **.unblock( )** <sup>&rArr; <code>PromiseType</code></sup> [`<>`](http://github.com/charto/cwait/blob/c57c0fd/src/TaskQueue.ts#L38-L46)  \n> > &emsp;<em>Consider current function idle until promise resolves.</em>  \n> > &emsp;<em>Useful for making recursive calls.</em>  \n> > &emsp;&#x25aa; promise <sup><code>PromiseType</code></sup>  \n> > **.wrap( )** <sup>&rArr; <code>(...args: any[]) =&gt; PromiseType</code></sup> [`<>`](http://github.com/charto/cwait/blob/c57c0fd/src/TaskQueue.ts#L51-L53)  \n> > &emsp;<em>Wrap a function returning a promise, so that before running</em>  \n> > &emsp;<em>it waits until concurrent invocations are below this queue's limit.</em>  \n> > &emsp;&#x25aa; func <sup><code>(...args: any[]) =&gt; PromiseType</code></sup>  \n> > &emsp;&#x25ab; thisObject<sub>?</sub> <sup><code>any</code></sup>  \n>  \n> Properties:  \n> > **.concurrency** <sup><code>number</code></sup>  \n> > &emsp;<em>Number of promises allowed to resolve concurrently.</em>  \n\nLicense\n=======\n\n[The MIT License](https://raw.githubusercontent.com/charto/cwait/master/LICENSE)\n\nCopyright (c) 2015-2017 BusFaster Ltd\n","maintainers":[{"name":"jjrv","email":"befunge@gmail.com"}],"time":{"modified":"2022-06-14T06:35:57.406Z","created":"2016-03-30T16:08:21.044Z","0.0.1":"2016-03-30T16:08:21.044Z","0.0.2":"2016-04-02T17:26:18.063Z","0.0.3":"2016-05-04T14:41:43.300Z","1.0.0":"2016-05-10T13:30:47.949Z","1.0.1":"2016-12-14T15:07:17.461Z","1.1.0":"2017-07-13T16:12:48.002Z","1.1.1":"2017-08-06T05:57:04.515Z","1.1.2":"2018-11-06T20:31:55.133Z"},"homepage":"https://github.com/charto/cwait#readme","repository":{"type":"git","url":"git+https://github.com/charto/cwait.git"},"author":{"name":"Juha Järvi"},"bugs":{"url":"https://github.com/charto/cwait/issues"},"license":"MIT","readmeFilename":"README.md","keywords":["promise","concurrent","concurrency","parallel","timeout","delay","wait","queue"]}