{"_id":"@async-cancellables/async-state","_rev":"1-2876f4d2087d9a9d1f5330fea6999608","name":"@async-cancellables/async-state","dist-tags":{"latest":"2.1.0"},"versions":{"2.0.0":{"name":"@async-cancellables/async-state","version":"2.0.0","description":"Asynchronous state with cancellation support","main":"index.js","type":"module","repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-state"},"keywords":["async","cancellable","AsyncState","cancellation"],"author":{"name":"vuwuv"},"license":"MIT","bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"homepage":"https://github.com/vuwuv/async-cancellables#readme","dependencies":{"@async-cancellables/ct":"^2.0.0"},"engines":{"node":">=18.0.0"},"gitHead":"cca86a13c78c2c9eab5806f11d8f7a298f20aec0","_id":"@async-cancellables/async-state@2.0.0","_nodeVersion":"18.13.0","_npmVersion":"9.3.1","dist":{"integrity":"sha512-8+tgZbNwHqBiOeveLN/e5xePCoxXp9jpwggjB3Ly/Zu4fB8aPxbpKRoHCeH+RKqpSAj0IEWtBtBpR71vlKGkIg==","shasum":"ea8f242a3ff2c593d6a8ea7ded604716f5c198b2","tarball":"https://registry.npmjs.org/@async-cancellables/async-state/-/async-state-2.0.0.tgz","fileCount":3,"unpackedSize":6586,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcwgtAWQ9O4Y/aUajOC6+0FHFOBQ0FfCjIgIVsZzZORwIhAJYqcTrIkuFk/bfGVTAf2ZEjcxLsl2Izntg2VLzCAMWX"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkBGTLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPaQ//bBAX/OwFVCDAf4DX6EKgBwWjU2BP8vIHzncNZ6iizHnukNeV\r\nCEUpySTJ3BNGqMujhn9/VOTbprqOpx4qRlOfGoSwegkbwdDLZnjSPYmFHonR\r\nTWcOA1IDlgyeHJrPZWlY61J//bBqVrg8O0kIHiibJpvLqLOHrgMlQP/jvuOT\r\nT8EIFYy7d2i7vIzXVIXYv3LAQ/smN9b+r1fNw864gLl8rktq3b4jd33ESdnB\r\nY1HhO4E56vQwPms3K7raOU2ZCm9V57yMxNZ2ZP8euqbKToHGPpacouo79ofy\r\nx8J/4r6OHDeCjDgFdrARdfvW9a/hzR6SslwaU4qhG/spOHqoZJKNl75GRBFr\r\nPg9byEI3oM1djXmz3Rzrtr2MbCZtt45Zmg2FhOhz6M/HhFUBAGSpMS1I2nke\r\nrYfgYPPhCxIEJWaUWIYAUxu82LeKHIn1SzP9X5+fDY5LnZL3gVkgwD5+iZKT\r\nqGu3zrD+pKtTDecIPhaFV2Nxj8c7FnXUtE+AtmBx09rLZBD1pL8/ii7qmrhp\r\nmA9vdaQmssyk/MRXPjeoOdWG4Rk5Ex0Vk1GPqKP+CULvZWBJGwkxZangcCc1\r\nFFTtdUOSNkukhv4uqIKTnvOkNFWbVaDISMLQniNzdBl6tAemH65WVHcnu2r6\r\n83fdJOu9I3vVYUdkWI3q1xP8XzFGfxQVUWo=\r\n=Lcsv\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-state_2.0.0_1678009547326_0.9880554307000609"},"_hasShrinkwrap":false},"2.1.0":{"name":"@async-cancellables/async-state","version":"2.1.0","description":"Asynchronous state with cancellation support","main":"index.js","type":"module","repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-state"},"keywords":["async","cancellable","AsyncState","cancellation"],"author":{"name":"vuwuv"},"license":"MIT","bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"homepage":"https://github.com/vuwuv/async-cancellables#readme","dependencies":{"@async-cancellables/ct":"^2.1.0"},"engines":{"node":">=18.0.0"},"gitHead":"286a1b8f801a432827adb845c47074d85aa338c6","_id":"@async-cancellables/async-state@2.1.0","_nodeVersion":"18.13.0","_npmVersion":"9.3.1","dist":{"integrity":"sha512-1X2uMpRy9RxMRRrjEoXgElfEZPibmnKX/Qn0yeKss9SG32Mozs3IlEp0JyhpJSXJmyI5Wki4UJuS8bKDgMcPRQ==","shasum":"33cca374f63c41e8a43faa3a906b24f0e7e67bd6","tarball":"https://registry.npmjs.org/@async-cancellables/async-state/-/async-state-2.1.0.tgz","fileCount":3,"unpackedSize":6586,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAqtRcgHhdwUUYkKIJny7CkuXzfjCQaXD+MTcylYiNCFAiEA7NlPbK1JstxmVAy25/Cfp3RC5WQlUa1xeuuOQjHTqEY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkB6WzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrTQRAAnsx8GokABnCJvhrDFflXetREUm8kVE8K6HKuFmSJ5sWPhGXH\r\nuSqwIYQ7Iy2rDvC2q/OQUhM5am77boWwuEG2ccu9hZu795th19I0wBH/AppY\r\nGmcho0gP4h5V/MeEMaZogAJ+PQDpOV/Ok4vKc3lz6bbxylH3+cg/wFRxvWiL\r\nj85RhKy6x7j8DjYW1royEKYjS/tZcFkD3BbSjRnRgx5KsooqAoX6yQtZEAYK\r\nYz6XmtHv8Zuly/T+0wfo5S3Dvd0EP3dSbZhCoyCHEfHTlR4hGMAcr1ktxxlR\r\nKHmeCwbWB9j/wXCtqYpcDNvFd1HafWGKU9YbkB9GQ38PCF1moxNWt/u6me2C\r\n07vikGe63mJ+6rMurgLYKfrnIT159zhvFHgZj5jyac9BraZf8QaMLkuxhwAM\r\nPg1TwopbUwONSOfIAePPbrSkDxfJNcNKf0SnNTlXvrhxETno7GqFyF61yY3k\r\nRvI+49jJT5KsfY56LD9qkKBiL3I08QkWnMVldbefpBTT7OekBNoLgAZQs3mf\r\nXzTn030t8bP2V6hIMmYV56QiE5DsTpymj+19SOEoodDmSYivB7ZlIcO9xMII\r\niBKzHKnexRnhqLLVKKEpeI5uoxMyfJUTt1ADbue0usV8zb81KRQHPcn9lNYC\r\nlAlc03XVfsIPF8vmXsyimSyJxFESuO3noT8=\r\n=SV52\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-state_2.1.0_1678222771731_0.22843305949341985"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-05T09:45:47.264Z","2.0.0":"2023-03-05T09:45:47.480Z","modified":"2023-03-07T20:59:32.010Z","2.1.0":"2023-03-07T20:59:31.905Z"},"maintainers":[{"name":"vuwuv","email":"vkhubb@gmail.com"}],"description":"Asynchronous state with cancellation support","homepage":"https://github.com/vuwuv/async-cancellables#readme","keywords":["async","cancellable","AsyncState","cancellation"],"repository":{"type":"git","url":"git+https://github.com/vuwuv/async-cancellables.git","directory":"packages/async-state"},"author":{"name":"vuwuv"},"bugs":{"url":"https://github.com/vuwuv/async-cancellables/issues"},"license":"MIT","readme":"# Async Cancellables / AsyncState\n\n> Asynchronous class to track presence or absence of a value with builtin support of cancellation tokens\n\n## Table of contents\n\n- [Prerequisites](#prerequisites)\n- [Table of contents](#table-of-contents)\n- [Installation](#installation)\n- [API](#api)\n    - [Creating state](#creating-state)\n    - [Waiting for a value](#waiting-for-a-value)\n    - [Accessing current value](#accessing-current-value)\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-state\n```\n\n## API\n\n### Creating state\n\nThere are 2 types of AsyncState:\n- `manual` state can be set only manually\n- `event` state sets value after specified event on target object is fired, state value is set to the result of handler call with event arguments\n\n```js\nimport { AsyncState } from 'async-cancellables';\n\nconst manualState = AsyncState.manual(value = undefined);\nconst eventState = AsyncState.event(target, event, handler);\n```\n\n### Waiting for the value\n\n- `wait(cancellationToken = null)` waits for the value to be set to any defined value or returns it if already is\n- `waitEmpty(cancellationToken = null)` waits for the value to be cleared back to `undefined`\n- `handleValue(handler, cancellationToken = null)` waits for the value to be set to any defined value if not yet and returns the result of `handler(value)`\n\n### Accessing current value\n\n- `value` simple property to access currently set value\n\n## Authors\n\n* **vuwuv** - *Initial work* - [vuwuv](https://github.com/vuwuv)\n\n## License\n\n[MIT License] © vuwuv","readmeFilename":"README.md"}