{"name":"get-ready","version":"3.0.0","description":"mixin to add one-time ready event callback handler","main":"lib/index.js","types":"lib/index.d.ts","dependencies":{},"devDependencies":{"@eggjs/tsconfig":"^1.3.3","@types/mocha":"^10.0.1","@types/node":"^20.2.5","egg-bin":"^6.4.1","eslint":"^8.42.0","eslint-config-egg":"^12.2.1","typescript":"^5.1.3"},"engines":{"node":">= 16.13.0"},"scripts":{"lint":"eslint .","test":"npm run lint && egg-bin test","ci":"egg-bin cov && npm run tsc","clean":"tsc -b --clean","tsc":"tsc","prepublishOnly":"npm run tsc"},"repository":{"type":"git","url":"git://github.com/node-modules/get-ready.git"},"keywords":["ready","get-ready","once","event"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},"license":"MIT","bugs":{"url":"https://github.com/node-modules/get-ready/issues"},"gitHead":"82c07e5bdc79b0bedc8f9a79de05cb5980ea0f6b","homepage":"https://github.com/node-modules/get-ready#readme","_id":"get-ready@3.0.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-0JNvz6IFnP6pHWbukMxNrtkHMg9uHZDHDqkVJi2yLpMeDPi8pUlnZKeSEmLbXFBHlHGetdzbX8mllGZVggxTBg==","shasum":"6d8495bb4f90e6745cce7a20c1d01bb58f7c5087","tarball":"http://registry-npm.ywwl.com/get-ready/download/get-ready-3.0.0.tgz","fileCount":5,"unpackedSize":9059,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/get-ready@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDscPP5f0mv2gQGWWb6g14ESNM0UcZCNdSPnT6mO28IewIhAMmwmNcN+RoWw0xpfV86/akjtXX6FpqbehB4xpp1Rp73"}],"size":3727,"noattachment":false,"key":"/get-ready/-/get-ready-3.0.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":"sakura9515@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/get-ready_3.0.0_1685945058815_0.41709897168811194"},"_hasShrinkwrap":false,"readme":"# get-ready\n\n[![NPM version][npm-image]][npm-url]\n[![CI](https://github.com/node-modules/get-ready/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/get-ready/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/get-ready.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/get-ready\n[codecov-image]: https://codecov.io/github/node-modules/get-ready/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/node-modules/get-ready?branch=master\n[download-image]: https://img.shields.io/npm/dm/get-ready.svg?style=flat-square\n[download-url]: https://npmjs.org/package/get-ready\n\n**Fork from [supershabam/ready](https://github.com/supershabam/ready)**\n\none-time ready event object.\n\n## Usage\n\nCreate `ready` event object.\n\n```ts\nimport { Ready } from 'get-ready';\n\nconst obj = new Ready();\n\n// register a callback\nobj.ready(() => console.log('ready'));\n\n// mark ready\nobj.ready(true);\n```\n\n### Register\n\nRegister a callback to the callback stack, it will be called when mark as ready, see example above.\n\nIf the callback is undefined, register will return a promise.\n\n```ts\nobj.ready().then(() => console.log('ready'));\nobj.ready(true);\n```\n\nIf it has been ready, the callback will be called immediately.\n\n```ts\n// already ready\nobj.ready(true);\nobj.ready().then(() => console.log('ready'));\n```\n\n**Warning: the callback is called after nextTick**\n\n### Emit\n\nMark it as ready, you can simply using `.ready(true)`.\n\nYou can also mark it not ready.\n\n```ts\nobj.ready(true);\n// call immediately\nobj.ready(() => console.log('ready'));\n\nobj.ready(false);\nobj.ready(() => throw 'don\\'t run');\n```\n\nWhen exception throws, you can pass an error object, then the callback will receive it as the first argument.\n\n```ts\nobj.ready(err => console.log(err));\nobj.ready(new Error('err'));\n```\n\n## License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/221826?v=4\" width=\"100px;\"/><br/><sub><b>supershabam</b></sub>](https://github.com/supershabam)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/360661?v=4\" width=\"100px;\"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/32174276?v=4\" width=\"100px;\"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|\n| :---: | :---: | :---: | :---: | :---: |\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jun 05 2023 14:06:50 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","publish_time":1685945058975,"_cnpm_publish_time":1685945058975,"dist-tags":{"latest":"3.4.0"}}