{"_id":"@broxus/await-semaphore","_rev":"13-3d8b24e2c402fd703d9237727584badb","name":"@broxus/await-semaphore","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.3":{"name":"@broxus/await-semaphore","version":"0.1.3","keywords":["promise","semaphore","mutex","typescript"],"author":{"name":"Emma Kuo"},"license":"MIT","_id":"@broxus/await-semaphore@0.1.3","maintainers":[{"name":"rexagon","email":"reide740@gmail.com"}],"homepage":"https://github.com/notenoughneon/await-semaphore#readme","bugs":{"url":"https://github.com/notenoughneon/await-semaphore/issues"},"dist":{"shasum":"4e7c588af3ff4283c542cf2fee1c9c028cba15fe","tarball":"https://registry.npmjs.org/@broxus/await-semaphore/-/await-semaphore-0.1.3.tgz","fileCount":5,"integrity":"sha512-6YSvNrYciMF7hS7/j9BdOdDXttZnZjEewzGmGoqH9Q4WteQiVwqDCwlTODjdi3Nkozw/2ETaflQbIKKBloZgbw==","signatures":[{"sig":"MEUCIQDQzK7EUbGfjLpxMvDg0sxZTSTz88YPOPHw/USxh86b5AIgPGvqFzjPC+ZekbHDMTjxCHx2rGnfDWSI4xO2EZkB1iM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5838,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjyePCRA9TVsSAnZWagAA4kgP/0+qWOGOb+nnh+yPPHRU\nxddb1FOs+vZNOpaNsvNdbufYk2ySRQvyLO8YFeNyRsze8km09HkyA8u7ug/x\ntEoz7jlhQJuKck9SrAqKNwvVGn+EiAKJFqTTxP3yP30qtiH7sCNwtHvuHZi/\nd6d45L/pRGs9ZFNyaRNu4htfR99CjVKI+6CmCLZf6pcxn+f772onngNjyZ2d\nxflKS2ER+K082Wwxt9m6UiaYGS7i3JW/T9qsGBGU2bM39IY6eLLndeRzRdEz\nzg7VBZM7a0+ZioHLZcF1KHY7NTbGfK+U0vykuI2oFaDbfw992F8laj9SNW0v\nMc515H+fUVoIrAsR+ODV26h2/APXTXO220rO2e5/aEC4qZG77hbaC+YPY6RS\nkMyx8G8LQEigNNf53D/p22uhkNuU0VNNifroMBLqjOIlRH5iBvg1xLoqmXB3\ny/pDHuB7LkSn6braAlH3eLGaECl5G+wdjGTZ//GPQJM2vh0nvYqyE42OXvC9\nqY/Yff1L8DJXJuxC586UmRpZuBh7lYVlexfQ8HZdoGhvtfb3E6hx2ZXQj+XU\nrqGCib3ioDVwLb5DS/gyzPdgnB0h2C7DJguWl5Mco5b0W/X/renIm8+R6IIA\nmxtySau0U8wJeOYXlM62ybkuWmz/23BiBAlVHRtRtH17Y3u6npGM1C8y+Jbk\nK9P7\r\n=8Rz5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"f117a6b59324038c9e8ee04c70c328215a727812","scripts":{"test":"mocha dist/test.js","build":"tsc"},"_npmUser":{"name":"rexagon","email":"reide740@gmail.com"},"repository":{"url":"git+https://github.com/notenoughneon/await-semaphore.git","type":"git"},"_npmVersion":"7.11.1","description":"Awaitable semaphore/mutex [Fork of await-semaphore]","directories":{},"_nodeVersion":"16.0.0","_hasShrinkwrap":false,"devDependencies":{"mocha":"^8.3.2","typescript":"^4.2.4","@types/node":"^15.0.1","@types/mocha":"^8.2.2"},"_npmOperationalInternal":{"tmp":"tmp/await-semaphore_0.1.3_1619994511140_0.20854594921817582","host":"s3://npm-registry-packages"}},"0.1.4":{"name":"@broxus/await-semaphore","version":"0.1.4","keywords":["promise","semaphore","mutex","typescript"],"author":{"name":"Emma Kuo"},"license":"MIT","_id":"@broxus/await-semaphore@0.1.4","maintainers":[{"name":"rexagon","email":"reide740@gmail.com"},{"name":"pavlovdog_","email":"pavlovdog.moscow@gmail.com"}],"homepage":"https://github.com/notenoughneon/await-semaphore#readme","bugs":{"url":"https://github.com/notenoughneon/await-semaphore/issues"},"dist":{"shasum":"b4999aa646bcb8c2245bde4541678786a832da44","tarball":"https://registry.npmjs.org/@broxus/await-semaphore/-/await-semaphore-0.1.4.tgz","fileCount":5,"integrity":"sha512-xh3JXQ+hvcwmx5r05u0eORJi5Vj/xoZFXL0YcoKeRuwbNH62p5Rs49UCq1VmrPVhLBI91VrWXsx9pJKOM6vKQw==","signatures":[{"sig":"MEUCIAo/WRECkDwCg6uXrS3qTj2TOrvl4mzJfjp4I3LX7YCeAiEArFBNoKFWYPpZ/gZcA2UMWfJM+KcPCg6hBNCN81uOYHs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6098,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAHekCRA9TVsSAnZWagAAW6kQAKBRlBQXo55ucsQXXMHZ\nBqOst5C2ZTVkskme57ugYkXktDh9qftFclDZDAldWGNupQANkhRehdb77+66\nLztv1EwySxEH+cTComiaqUvrCUDDCwIZKHI1zGu1KoUkrMJ/So2cGlwwEKP8\n1BTp496IT5HXYd+dOt3hzOZOT//dwaIZjO/ci7L9hh5dnTzp+XZ6JBv9633O\nyRNf0PPc2wOo7svTcDgzwNq0nKtCI5URM3tqkAyp2vPEt6yRerwvdjB4fpG/\neRmxxBdMvNOgNY/tZIriDLd5l1ovJPyON2U1dPFQz4mbChVSZVbcXcwrxDdi\ndFrg6FVwazh4OjRQp/Z4klYYdgGsmxFLmeiOEPG/YJW0FQkC0VvIaa5RB7LG\nF7kcNtx4Wq/MukfeHtrvkHJUQ7HYPcVxf4lqLIywlP80llgN8DYUD+d9b72N\nLfN6XhbvrGSWehFiqXI1deK0or1ffO2i1rxWAMpzat4ZOzOkHNf4273VL60F\nXw2JsbgjwSsL6fnEkuaImzacj+K+gCip8rl/E4r3ikERUi4wT8I3d2sP+BS/\n/8JQ8fQrDpKXZb65CkTlX+wvXLhAw+W8jUZ/M3tkKw0/pUBYu/Ba0lStmxpK\nIwNFNt8UPCPW+0Q9XkJQonUePlcUJ/UR7jeLLuKz2vvjUfxrsRZUCOlOgNVJ\n2GcI\r\n=12ca\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d295e61122831864ee4a08c91fe4b5146250ddca","scripts":{"test":"mocha dist/test.js","build":"tsc"},"_npmUser":{"name":"rexagon","email":"reide740@gmail.com"},"repository":{"url":"git+https://github.com/notenoughneon/await-semaphore.git","type":"git"},"_npmVersion":"7.17.0","description":"Awaitable semaphore/mutex [Fork of await-semaphore]","directories":{},"_nodeVersion":"16.5.0","dependencies":{"next-tick":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^8.3.2","typescript":"^4.2.4","@types/node":"^15.0.1","@types/mocha":"^8.2.2","@types/next-tick":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/await-semaphore_0.1.4_1627420580307_0.04589933117138201","host":"s3://npm-registry-packages"}},"0.1.5":{"name":"@broxus/await-semaphore","version":"0.1.5","keywords":["promise","semaphore","mutex","typescript"],"author":{"name":"Emma Kuo"},"license":"MIT","_id":"@broxus/await-semaphore@0.1.5","maintainers":[{"name":"geronimo","email":"plitnichenko@gmail.com"},{"name":"rexagon","email":"reide740@gmail.com"},{"name":"pavlovdog_","email":"pavlovdog.moscow@gmail.com"}],"homepage":"https://github.com/notenoughneon/await-semaphore#readme","bugs":{"url":"https://github.com/notenoughneon/await-semaphore/issues"},"dist":{"shasum":"e5fcf641dfa71ffc29210b1138e2157a32b422d9","tarball":"https://registry.npmjs.org/@broxus/await-semaphore/-/await-semaphore-0.1.5.tgz","fileCount":5,"integrity":"sha512-g464HtHHKxk6r6bkZc+lET1PuSgcFxlLHVb7EAqfxTlx6DRcYkjPRIQQhRHB3BQ6zRpfMrYkppL0tBtRED+HNA==","signatures":[{"sig":"MEUCIQCTyxuPLRh8eszWmMk+5oLbwxJHWsBkihTBBh6JT4Z3fAIgZm7VMqI7hUQLAbjbGFzG2sDZa6GJBXSyv91G3tmddwQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8309,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiMIogACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqUmg/7BwpeQe7/Q9Ezy6Xc3ruigu7qp2nBuEASowhn/sG46MtXDO42\r\n5tS5hiwQEH1o91AHSItFINkP1L2B+PW2IDJtsVvzOjRDB698q6feAqQsFUAH\r\ne8kGewViQ+vJruqlmLzvfYRtKtjKvqORcA9Q4/M4BVSAgmX7IbicJy2dcpLZ\r\n8XKkAksDAvV9qLyaZGLPqK7kT8DHoclZJf1J0sMva0DrVoaVWqufz2UYJzoM\r\nWSbfXQ2xGt4WHF3kw1lVgeV/gHEebL8c0d63MBRTOpe05Svn4ycrAKBd+5zo\r\nyJNBAuuXI94GC1ehwL5G2agMELF1q0GA9alrxLjO9uA2arzC9Ix/MO6RbCC+\r\ncajGP1nuLnSqoApVVnvePyONjxO/wiw4D1k5qxcGZ7mKUNPoFvty5mNvDLYN\r\nQP+TX8O0iFFexdk00pGnPPVmh96K6nlG+nAigeRWBhYCGvTlzyBrUEGhpX6n\r\nIHuVlEJYrRTxL2OB0VNgoX84e0kzlSYk/R81lDhP7Jf8R48MXWkiHSM9CdNY\r\nRG2ANaDmvRlaGc848KjTyKcuaCZ55g2GaoEiV/GLAePjlYT2/CJMsqQhjKBX\r\nLKSNQ7YOK+WctgxNSsKjPQOlMPvhfPgiOj99OJBBZH6QUSO52dDg6rkXLAi+\r\nPyq81PqjhWB4j0wr/gZHJD0Jzo5caIGFiFI=\r\n=bhld\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d4b4cff7cd09727f1323649fa510c80ce8f1a470","scripts":{"test":"mocha dist/test.js","build":"tsc"},"_npmUser":{"name":"rexagon","email":"reide740@gmail.com"},"repository":{"url":"git+https://github.com/notenoughneon/await-semaphore.git","type":"git"},"_npmVersion":"8.5.4","description":"Awaitable semaphore/mutex [Fork of await-semaphore]","directories":{},"_nodeVersion":"17.7.1","_hasShrinkwrap":false,"devDependencies":{"mocha":"^8.3.2","typescript":"^4.2.4","@types/node":"^15.0.1","@types/mocha":"^8.2.2","@types/next-tick":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/await-semaphore_0.1.5_1647348255915_0.8520900380342518","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-05-02T22:28:30.787Z","modified":"2025-12-16T11:41:03.507Z","0.1.3":"2021-05-02T22:28:31.290Z","0.1.4":"2021-07-27T21:16:20.483Z","0.1.5":"2022-03-15T12:44:16.084Z"},"bugs":{"url":"https://github.com/notenoughneon/await-semaphore/issues"},"author":{"name":"Emma Kuo"},"license":"MIT","homepage":"https://github.com/notenoughneon/await-semaphore#readme","keywords":["promise","semaphore","mutex","typescript"],"repository":{"url":"git+https://github.com/notenoughneon/await-semaphore.git","type":"git"},"description":"Awaitable semaphore/mutex [Fork of await-semaphore]","maintainers":[{"email":"reide740@gmail.com","name":"rexagon"},{"email":"hello@sergeypotekhin.com","name":"pavlovdog_"},{"email":"plitnichenko@gmail.com","name":"geronimo"},{"email":"steam.30mb1@gmail.com","name":"30mb1"},{"email":"odrin666@gmail.com","name":"odrin"},{"email":"sudokey@gmail.com","name":"pavel337"},{"email":"pretoriannbox@gmail.com","name":"maxpretorian"},{"email":"karneges2012@gmail.com","name":"karneges1"}],"readme":"# await-semaphore\n> NOTE: it is a fork of old [`await-semaphore`](https://www.npmjs.com/package/await-semaphore) package but with some fixes\n\nAwaitable semaphore/mutex\n\nA semaphore implementation using ES6 promises and supporting 3 styles:\n\n* async/await style (needs typescript)\n* thunk style (automatic acquire/release)\n* promise style\n\nAlso includes `Mutex` as a convenience for `new Semaphore(1)`.\n\n## API\n\n### new Semaphore(count: number)\n\nCreate a new semaphore with the given count.\n\n```javascript\nimport {Semaphore} from 'await-semaphore';\n\nvar semaphore = new Semaphore(10);\n```\n\n### semaphore.acquire(): Promise<() => void>\n\nAcquire the semaphore and returns a promise for the release function. Be sure to handle release for exception case.\n\n```javascript\nsemaphore.acquire()\n.then(release => {\n    //critical section...\n    doSomething()\n    .then(res => {\n        //...\n        release();\n    })\n    .catch(err => {\n        //...\n        release();\n    });\n});\n```\n\n### semaphore.use<T>(thunk: () => Promise<T>): Promise<T>\n\nAlternate method for using the semaphore by providing a thunk. This automatically handles acquire/release.\n\n```javascript\nsemaphore.use(() => {\n    //critical section...\n});\n```\n\n### new Mutex()\n\nAn alias for `new Semaphore(1)`. Mutex has the same methods as Semaphore.\n\n```javascript\nimport {Mutex} from 'await-semaphore';\n\nvar mutex = new Mutex();\n```\n\n## Examples\n\nCreate a version of `fetch()` with concurrency limited to 10.\n\n### async/await style (typescript)\n\n```typescript\nvar semaphore = new Semaphore(10);\n\nasync function niceFetch(url) {\n    var release = await semaphore.acquire();\n    var result = await fetch(url);\n    release();\n    return result;\n}\n```\n\n### thunk style (javascript)\n\n```javascript\nvar semaphore = new Semaphore(10);\n\nfunction niceFetch(url) {\n    return semaphore.use(() => fetch(url));\n}\n```\n\n### promise style (javascript)\n\n```javascript\nvar semaphore = new Semaphore(10);\n\nfunction niceFetch(url) {\n    return semaphore.acquire()\n    .then(release => {\n        return fetch(url)\n        .then(result => {\n            release();\n            return result;\n        });\n    });\n}\n```\n","readmeFilename":"README.md"}