{"_id":"promise-concurrency-limiter","_rev":"374210","name":"promise-concurrency-limiter","description":"Tiny scheduler for functions returning promises that can limit their concurrency.","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"time":{"modified":"2024-06-18T11:19:41.000Z","created":"2020-12-29T20:10:26.949Z","2.0.1":"2024-04-04T23:04:17.275Z","2.0.0":"2022-04-07T19:26:48.221Z","1.0.0":"2020-12-29T20:10:26.949Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/fabiospampinato/promise-concurrency-limiter.git"},"versions":{"2.0.1":{"name":"promise-concurrency-limiter","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/promise-concurrency-limiter.git"},"description":"Tiny scheduler for functions returning promises that can limit their concurrency.","version":"2.0.1","type":"module","main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["promise","concurrency","limiter","limit"],"devDependencies":{"fava":"^0.2.1","tsex":"^3.0.1","typescript":"^5.1.6"},"_id":"promise-concurrency-limiter@2.0.1","gitHead":"ae0788a2516bbcb9b430ed38540ad36179d7a7fc","bugs":{"url":"https://github.com/fabiospampinato/promise-concurrency-limiter/issues"},"homepage":"https://github.com/fabiospampinato/promise-concurrency-limiter#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-aJ9jJIUDSV+gf1O+pm8xgYqebLo4a7n1Hnu2h/oNI43WLqtk+RuGNECad0kK17gIt9n4SPQ+9VVvYdmjZdBPXg==","shasum":"69348be2f775019f647694eadd2bff989edb207d","tarball":"http://registry-npm.ywwl.com/promise-concurrency-limiter/download/promise-concurrency-limiter-2.0.1.tgz","fileCount":12,"unpackedSize":7313,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGcCDTXkAklXDZg0xdiTYR2e+cVC02Ll3BjUrZl386TAIgI8Sblb6RT7sGgwPYTmJ2NCxWjlT2iEylQIRKg4WB4+Y="}],"size":3032,"noattachment":false,"key":"/promise-concurrency-limiter/-/promise-concurrency-limiter-2.0.1.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-concurrency-limiter_2.0.1_1712271857069_0.5411174306362936"},"_hasShrinkwrap":false,"publish_time":1712271857275,"_cnpm_publish_time":1712271857275},"2.0.0":{"name":"promise-concurrency-limiter","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/promise-concurrency-limiter.git"},"description":"Tiny scheduler for functions returning promises that can limit their concurrency.","version":"2.0.0","type":"module","main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"npm run clean && npm run compile && npm run test"},"keywords":["promise","concurrency","limiter","limit"],"devDependencies":{"fava":"^0.0.6","tsex":"^1.1.0","typescript":"^4.6.3"},"gitHead":"5016797cfd5608f5cdfac78fae34053477f51c36","bugs":{"url":"https://github.com/fabiospampinato/promise-concurrency-limiter/issues"},"homepage":"https://github.com/fabiospampinato/promise-concurrency-limiter#readme","_id":"promise-concurrency-limiter@2.0.0","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-5OrlVWGMCp1HXPur1aRP00mCXmKGTPu/Cucaj4v37SSxeEiQmupLk5iIaxT9WytzMIgUzAzSQcwOCsXQ5Hxgeg==","shasum":"2ad2730d2ff0904de4aeb932be5bbaf927e0ecfe","tarball":"http://registry-npm.ywwl.com/promise-concurrency-limiter/download/promise-concurrency-limiter-2.0.0.tgz","fileCount":12,"unpackedSize":6701,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG//mSr51YgchCnmG2KfoiP7glJ5IlwcEi3jqU8Lss6wAiAVCzb7nFPxkHn5ptjircVQ8UkJ2+I66K3cjKFEf8u5dg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiTzr4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/2A//Ul3J0HlbrVdtyKFyJEUyF29g8QMZMhGecEkVyd7x0jwyCyjl\r\ntNk0b63nGO6ghkYYwbCJYTrJeCSInSahImloU6OSbcn/CL+wlhokM/bnnf5X\r\nFFpNzqIl11MRkA4aZx+7JUnaSzZDjH49nXwjlt1yifJtXxv5vNjKVAW3hMCb\r\nGJHTc86rOsipRMDCxv3xggP7jZzHS2lCiE53j4SIFFxHVeeiVajuhEfDPQJ6\r\nu9CNLYh27BwUpSfQb5hqP3JbCETBfyH5o5jRkRts3oGANUrpoxe10Hf0NvGF\r\nYRYT2MGv3PsL6504lWKullit83OsJ0V8y0q6ohiptfcOgoa92Vpd4uupmCkr\r\nyhw5o20VdhIywsQ9j62WMelB0Mn5YFDdYJxEAgmpOkzzagRKQFFA5c9Yf24k\r\nKrCLZNxIP3UKE1N7Y+Q3hkwHALk/cTGiusnlPhYpmPsHld5h+ZX7/wtBP7G7\r\n7efszW3e4h3rhc2sSk5hMpa32Rq4CZachvZZCY/OFUfSLe2AEUvztL7r6iw8\r\nGW6Zrg5KrYRYnw22Bi55L7+9ImFltO11anH8d7CMakn5wbLnc8sOfjnLp1iJ\r\nEUYXzvlGGwkd9VWNVB3tngICz3PcvlC0Yr0MTerpshThQgD7jEymRQSuMFJJ\r\nTfwYe9/8xaem5eUCq2+otOIek6g5vIvlWMA=\r\n=g1Q7\r\n-----END PGP SIGNATURE-----\r\n","size":2760,"noattachment":false,"key":"/promise-concurrency-limiter/-/promise-concurrency-limiter-2.0.0.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-concurrency-limiter_2.0.0_1649359608022_0.921720007395572"},"_hasShrinkwrap":false,"publish_time":1649359608221,"_cnpm_publish_time":1649359608221},"1.0.0":{"name":"promise-concurrency-limiter","description":"Tiny scheduler for functions returning promises that can limit their concurrency.","version":"1.0.0","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"clean:dist":"rimraf dist","clean:coverage":"rimraf coverage .nyc_output","clean":"npm run clean:dist && npm run clean:coverage","compile":"tsc --skipLibCheck && tstei","compile:watch":"tsc --skipLibCheck --watch","test":"ava","test:watch":"ava --watch","coverage":"nyc --reporter=html ava","report":"nyc report","report:html":"open coverage/index.html","prepublishOnly":"npm run clean && npm run compile && npm run coverage"},"ava":{"files":["test/index.js"]},"bugs":{"url":"https://github.com/fabiospampinato/promise-concurrency-limiter/issues"},"license":"MIT","author":{"name":"Fabio Spampinato","email":"spampinabio@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/fabiospampinato/promise-concurrency-limiter.git"},"keywords":["promise","concurrency","limiter","limit"],"dependencies":{},"devDependencies":{"@types/node":"^12.19.11","ava":"^2.4.0","ava-spec":"^1.1.1","nyc":"^15.1.0","rimraf":"^3.0.2","typescript":"^4.1.3","typescript-transform-export-interop":"^1.0.2"},"gitHead":"fd14ff4e3ea8ba335f65ebdb8f59b14af377d3cd","homepage":"https://github.com/fabiospampinato/promise-concurrency-limiter#readme","_id":"promise-concurrency-limiter@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"dist":{"integrity":"sha512-OI96yL5DUck9KCLee5H6DnRfVsHIstQspXk8xsYrWr9ur9IlFuzKvoU70HwQb99MqHg2mpdkuGa92NuoXue3cw==","shasum":"7f24c336fa21fe0c36a1ed1b17ad6f67dca45f2a","tarball":"http://registry-npm.ywwl.com/promise-concurrency-limiter/download/promise-concurrency-limiter-1.0.0.tgz","fileCount":12,"unpackedSize":8229,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf640zCRA9TVsSAnZWagAAfAQP/0mkaP8yDzsMMH+BKMiz\n59LMmbofGCPnjt0+8WyVqyp7XzM8/LzgzCObPbINkWrDARK4PeCa9hCeJvza\n3TA2M3/tXqGdcdlCzmdSkc8dOa2QrVwXjh6MS/OWA+dVS+s3y1iuNlm1VXwX\n5FGAbVJAhQxojPlhZGMFkuPTxXtUnS7KybCAVhpBSvKI60ASHoT34Xhueun7\n/iZK+pCK8OgYcON7D7C7Gu2QyEZ4YikLl6bb909CkEmKVLFF9PhgVeg9OTSa\nR3CRuClDPujxLCVn4o8fjZngpI537dgO5UZpwg4O9WUTiQcYwfanX+nAkIUB\nUF6U1PDOS88wTNK0/tJdEcWPcVpIpjPhVfwDUEsn4nNKTYdfgFfRvoSVzzKe\n2nC8CjvKsdg3+DA+Teoq9Hk/YJWbx7Em3vJKDaiz6XClLD/bgSWtONemrKGk\nxNFwVrk3aviUoYzw4BLju3F7vt3hxyXc5ZydgzDaC3xEYCuL3gdCytBHJKLs\ntPmIVad3sa7H15ODjlbn1lIbJvS9NdSxESulF6cvEtP7nFF5vgkqgJsBRXyb\n4szhsNqSMTiaDTxhC2Q3ZND27X67ZgFNYcpfI2F0LnR2EBgHZheApy8QQQy3\ncVx9di08PylJXq0sHY7XGffMCf0+NEZ6maalz5mV8jxXjP6Iw1HL3/CSeq5F\nCuDG\r\n=S8Cr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB7jJmgVpvmv/84hAJnl8lY0qVpqYo6/3rLDRobctVRWAiEA2H256Wq2wK2EtEuGhIYBqJ5bd7mVuqDD6E8aWVHvAMI="}],"size":3442,"noattachment":false,"key":"/promise-concurrency-limiter/-/promise-concurrency-limiter-1.0.0.tgz"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-concurrency-limiter_1.0.0_1609272626710_0.5115020419920078"},"_hasShrinkwrap":false,"publish_time":1609272626949,"_cnpm_publish_time":1609272626949}},"readme":"# Promise Concurrency Limiter\n\nTiny scheduler for functions returning promises that can limit their concurrency.\n\n## Install\n\n```sh\nnpm install --save promise-concurrency-limiter\n```\n\n## Usage\n\n```ts\nimport Limiter from 'promise-concurrency-limiter';\n\nconst limiter = new Limiter ({\n  concurrency: 2 // Limit the number of simultaneously active promises to 2\n});\n\nconst somePromiseReturningFunction = async () => { /* ... */ };\n\nlimiter.add ( somePromiseReturningFunction ); // First function added, executed immediately\nlimiter.add ( somePromiseReturningFunction ); // Second function added, executed immediately\nlimiter.add ( somePromiseReturningFunction ); // Third function added, executed immediately only if one of the 2 available slots got freed, deferred otherwise\n```\n\n## Deadlocks\n\nNote that if your concurrency-limited functions can also schedule other concurrency-limited functions you can get in a deadlock situation, where if the concurrency limit is N, and you have N currently executing functions, but all of those functions need to schedule other functions before they can resolve, then nothing will happen because all the available spots are filled already, and no current function will ever resolve.\n\nFor situations like that, unless you have some assurances that a deadlock can't actually happen, this library may not be the appropriate way to limit concurrency for your use case.\n\n## License\n\nMIT © Fabio Spampinato\n","_attachments":{},"homepage":"https://github.com/fabiospampinato/promise-concurrency-limiter#readme","bugs":{"url":"https://github.com/fabiospampinato/promise-concurrency-limiter/issues"}}