{"_id":"@async-cancellables/async-cooldown-queue","_rev":"1-81bbc7025c61bd0f2944e29f568a7b88","name":"@async-cancellables/async-cooldown-queue","dist-tags":{"latest":"2.1.0"},"versions":{"2.0.0":{"name":"@async-cancellables/async-cooldown-queue","version":"2.0.0","description":"Asynchronous cooldown queue and cancellation support","main":"index.js","type":"module","repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-cooldown-queue"},"keywords":["async","cancellable","AsyncCooldownQueue","cooldown","cancellation"],"author":{"name":"vuwuv"},"license":"MIT","bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"homepage":"https://github.com/vuwuv/async-cancellables#readme","peerDependencies":{"@async-cancellables/ct":"^2.0.0"},"engines":{"node":">=18.0.0"},"gitHead":"cca86a13c78c2c9eab5806f11d8f7a298f20aec0","_id":"@async-cancellables/async-cooldown-queue@2.0.0","_nodeVersion":"18.13.0","_npmVersion":"9.3.1","dist":{"integrity":"sha512-YeQ/GfjzCxucrGMZONfsdykQOzKk2wUEThPBvEnb7gO03QKVnHsyfQjnz5crC7YLWSTTKRfVTlaRy2M1vVd/5g==","shasum":"02470b7d9c170f64dc5d68e2edaedd03986a87a4","tarball":"https://registry.npmjs.org/@async-cancellables/async-cooldown-queue/-/async-cooldown-queue-2.0.0.tgz","fileCount":3,"unpackedSize":5749,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJp0YjRWJBAvfI4tCH0jteykoAgcaofFLR+nhNQ9Qs2QIhAOTxo5Ur6g661ZUNkENL1jGwH2KWLuDOoCW5NV+aCmhW"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkBGTFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqg7BAAilOBvahZdrHcen6Zqar3qj4TXsKoTu56hUcrAIX4saR5qPhn\r\nfg4+FTf0s4jnxYT6Mk+od1qHvxHgHoAmLnTKRusylDZMLbU4RHGExN446FFN\r\n6p/zkxo/qlWjANwg0TUKAAUaUzpRezXJZaQIDdcmJVCgIcy3HO4d8nWEKlg2\r\nvBTsW6pmuM+U05PT95HrSplLPauQCQtw1EHs7uUR51+HoGsRqTTaRqiX3Gk7\r\ngTeXUOGyg0M+ur468s8AcvDs2ZUdv7xf2QrryycikCQtMVh0qpJsIq5Jjt3e\r\nJ4UhRWwHqSW1w/u2uHcHUnOeFBA/Rgpp8MQmb5C5jh31G3YdyLaiECHeivrj\r\nojuCONJEiQpT6ha0HLxQENc1icCXcF/Ck+F2T+rtv53PtaIkVm1qUjftGYND\r\nFBxhpkB9fPhFJ4JOY5KGZidxv7028dGrVtDcxnNd0/H7YrOuKIGcKHCSFwaI\r\ntII1srg27ekNu44p00PKAxwKMHwZvjb42BO0zNyfICQmTf1RMNeKnXHcW9dB\r\n31rc8UjI6yJqIltb9TEkX2k4vfItP/4TABUzw8LGmXxg+300bIH1OkghFbt1\r\n7xD4eAfWbFFVs9LB8NIo2acBfOs9kkJ5pmEyIs9TlXWb5M01rSoXeiUQ+w5B\r\ngr1s4si/XNO0ab1Mo9urBl7xz+UvDAhYh08=\r\n=yOC6\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"vuwuv","email":"vkhubb@gmail.com"},"directories":{},"maintainers":[{"name":"vuwuv","email":"vkhubb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-cooldown-queue_2.0.0_1678009541529_0.7377097604599319"},"_hasShrinkwrap":false},"2.1.0":{"name":"@async-cancellables/async-cooldown-queue","version":"2.1.0","description":"Asynchronous cooldown queue and cancellation support","main":"index.js","type":"module","repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-cooldown-queue"},"keywords":["async","cancellable","AsyncCooldownQueue","cooldown","cancellation"],"author":{"name":"vuwuv"},"license":"MIT","bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"homepage":"https://github.com/vuwuv/async-cancellables#readme","peerDependencies":{"@async-cancellables/ct":"^2.1.0"},"engines":{"node":">=18.0.0"},"gitHead":"286a1b8f801a432827adb845c47074d85aa338c6","_id":"@async-cancellables/async-cooldown-queue@2.1.0","_nodeVersion":"18.13.0","_npmVersion":"9.3.1","dist":{"integrity":"sha512-V9kJkKURQHT6Ba+2Za0GwcoIgPWN9mKr6wYtYZkyZSmqNxpFgcW9klbiU9gMuvJ8+9LFaULTf4zhRw2+XzC++w==","shasum":"685e33b237cdca8c068d89636e8c8d1b16630808","tarball":"https://registry.npmjs.org/@async-cancellables/async-cooldown-queue/-/async-cooldown-queue-2.1.0.tgz","fileCount":3,"unpackedSize":5749,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBy6y9t4MTyqXov7+82czzqm5AWZO8yb6JdGCtdz6n+gIhAInHuQI1gTfHDKCECm3xdGzmM33EkOEnQKzVEeSPi3Zs"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkB6WuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpznA/+KXq50Fx6VVQyDPUcFe63G+4QkFhJrUi3TxW2/SjkkLNFOk78\r\nyvw//0cuzZ+WaA8BhUWBMSi4lmXYlTQQdFcxXZQl0lZA/cg4EDBdODQnh579\r\n9EzKhKeHOhxC01EoZEw8LXn9xMkwIH9L32zKixxGxNPV8bn1CYHwtktdJLhu\r\n9pO1jM7Nw9fxH3MIUDf5ve4ZK+wFPpLpLYcTokqvUAAK4JzrikBRd9iNScnJ\r\nJRrgQV5lQsNQF92mTFm2J9dTtlAUJeK/Y8EYpOJ916hsIO+hx1liZhRtnAs7\r\nvGFLxPtmNdNsU0GgM8XJiF/2XzkV+E9yGNqxMnVWwZFSPVTuHgPFA/0Rkh/t\r\nPqleuDOFihvLUoSn1AYsAX+rjJe1mc0F4Nl4UNHR2h9nkD5V15hlFmAM8aK8\r\nNixvezi2AToLmM/3zBTQXiCQhNu6XDi4rDSo2HP4QjDsORGnRZoYK2fS6iB6\r\nuiFmm+a4X356k14lAfmWmk8/sZyxQp1q7U856Ak7FdTWA/DzUIq18zIz3mF1\r\ny01K81TeXzvvh4bKve+L2eqfpMbDDA1/sJiuKGmDy9VDTladCWZvfLGEtJdV\r\nVCDwkkh6AUcX8+kMEUbCF8aGetVdrFVbzY6bBNBuQEwNk9pFvI3D4z6D0Utt\r\nh72+FkwECTyqe4wmmzjQUctru2DW/2znYE8=\r\n=31u5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"vuwuv","email":"vkhubb@gmail.com"},"directories":{},"maintainers":[{"name":"vuwuv","email":"vkhubb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-cooldown-queue_2.1.0_1678222766113_0.48151753279628284"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-05T09:45:41.463Z","2.0.0":"2023-03-05T09:45:41.675Z","modified":"2023-03-07T20:59:26.501Z","2.1.0":"2023-03-07T20:59:26.379Z"},"maintainers":[{"name":"vuwuv","email":"vkhubb@gmail.com"}],"description":"Asynchronous cooldown queue and cancellation support","homepage":"https://github.com/vuwuv/async-cancellables#readme","keywords":["async","cancellable","AsyncCooldownQueue","cooldown","cancellation"],"repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-cooldown-queue"},"author":{"name":"vuwuv"},"bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"license":"MIT","readme":"# Async Cancellables / AsyncCooldownQueue\n\n> Asynchronous cooldown queue class provides cooldown control and supports cancellation tokens.\n\n## Table of contents\n\n- [Prerequisites](#prerequisites)\n- [Table of contents](#table-of-contents)\n- [Installation](#installation)\n- [Example](#example)\n- [API](#api)\n    - [Creating queue](#creating-queue)\n    - [Waiting for cooldown](#waiting-for-cooldown)\n    - [Getting waiters information](#getting-waiters-information)\n- [Authors](#authors)\n- [License](#license)\n\n## Prerequisites\n\nThis project requires NodeJS (version 18 or later) and NPM.\n\n## Installation\n\nTo install and set up the library, run:\n\n```sh\n$ npm install @async-cancellables/async-cooldown-queue\n```\n\n### Example\n\nFunction that can send a message no more than once in 2 seconds. The function will wait for the cooldown to end before sending the message. If `ct` is provided, the function will throw if the cancellation token is cancelled before the cooldown ends and quit the cooldown queue.\n\n```js\nimport AsyncCooldownQueue from '@async-cancellables/async-cooldown-queue';\n\nconst cooldownQueue = new AsyncCooldownQueue(2000);\n\nasync sendMessage(text, ct = null) {\n    await cooldownQueue.wait(ct);\n    socket.emit('message', text);\n}\n```\n\n## API\n\n### Creating queue\n\n`new AsyncCooldownQueue()` creates new queue.\n\n### Waiting for cooldown\n\nThere are two wait methods:\n- `wait(ct = null)` waits for the cooldown to end. If `ct` is provided, the function will throw if the cancellation token is cancelled before the cooldown ends and quit the cooldown queue.\n- `waitTime(time, ct = null)` same as `wait` but waits for `time` milliseconds instead of the default cooldown time.\n\n### Getting waiters information\n\n- `waitersPresent` returns `true` if there are waiters in the queue\n- `waitersCount` returns the number of waiters in the queue\n- `timeUntilAvailable` returns the time in milliseconds until the queue can immediately allow a waiter to proceed\n\n## Authors\n\n* **vuwuv** - *Initial work* - [vuwuv](https://github.com/vuwuv)\n\n## License\n\n[MIT License] © vuwuv","readmeFilename":"README.md"}