{"_id":"ready-callback","_rev":"1213126","name":"ready-callback","description":"Launch server after all async task ready","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"modified":"2021-10-13T05:46:41.000Z","created":"2015-10-20T15:40:45.717Z","2.1.0":"2018-08-21T10:36:10.072Z","2.0.1":"2017-02-12T17:14:17.978Z","2.0.0":"2017-02-09T13:49:41.483Z","1.0.0":"2015-10-20T15:40:45.717Z"},"users":{},"author":{"name":"popomore","email":"sakura9515@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/node-modules/ready-callback.git"},"versions":{"2.1.0":{"name":"ready-callback","version":"2.1.0","description":"Launch server after all async task ready","keywords":["koa","ready","async"],"main":"lib/ready.js","files":["index.js","lib"],"dependencies":{"debug":"^2.6.0","get-ready":"^2.0.0","once":"^1.4.0","uuid":"^3.0.1"},"devDependencies":{"autod":"^2.7.1","egg-bin":"^1.11.1","egg-ci":"^1.1.0","eslint":"^3.15.0","eslint-config-egg":"^3.2.0","koa":"^1.2.4","mz-modules":"^2.1.0","spy":"^1.0.0"},"repository":{"type":"git","url":"git+https://github.com/node-modules/ready-callback.git"},"homepage":"https://github.com/node-modules/ready-callback","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"autod":"autod","lint":"eslint .","test":"npm run lint -- --fix && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && egg-bin cov"},"engines":{"node":">=4.0.0"},"ci":{"version":"4, 6, 7"},"gitHead":"2a383cb24fe850e0e5d9d06db5773f563acbc7bb","bugs":{"url":"https://github.com/node-modules/ready-callback/issues"},"_id":"ready-callback@2.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.4.0","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"dist":{"shasum":"e382a9e33a568b8d771e04ef4ef0eb02d3dfa7e0","size":3463,"noattachment":false,"key":"/ready-callback/-/ready-callback-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ready-callback/download/ready-callback-2.1.0.tgz"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ready-callback_2.1.0_1534847769959_0.22535173148050758"},"_hasShrinkwrap":false,"publish_time":1534847770072,"_cnpm_publish_time":1534847770072},"2.0.1":{"name":"ready-callback","version":"2.0.1","description":"Launch server after all async task ready","keywords":["koa","ready","async"],"main":"lib/ready.js","files":["index.js","lib"],"dependencies":{"debug":"^2.6.0","get-ready":"^2.0.0","once":"^1.4.0","uuid":"^3.0.1"},"devDependencies":{"autod":"^2.7.1","egg-bin":"^2.0.2","egg-ci":"^1.1.0","eslint":"^3.15.0","eslint-config-egg":"^3.2.0","koa":"^1.2.4","spy":"^1.0.0"},"repository":{"type":"git","url":"git+https://github.com/node-modules/ready-callback.git"},"homepage":"https://github.com/node-modules/ready-callback","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"autod":"autod","lint":"eslint .","test":"npm run lint -- --fix && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && egg-bin cov"},"engines":{"node":">=4.0.0"},"ci":{"version":"4, 6, 7"},"gitHead":"ac54afad48a37e7e14df881812d90821ebc0b729","bugs":{"url":"https://github.com/node-modules/ready-callback/issues"},"_id":"ready-callback@2.0.1","_shasum":"579d972a2137a46c233cec5a013356bb45f2d046","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.5","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"579d972a2137a46c233cec5a013356bb45f2d046","size":3183,"noattachment":false,"key":"/ready-callback/-/ready-callback-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/ready-callback/download/ready-callback-2.0.1.tgz"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/ready-callback-2.0.1.tgz_1486919656146_0.043568355264142156"},"directories":{},"publish_time":1486919657978,"_cnpm_publish_time":1486919657978,"_hasShrinkwrap":false},"2.0.0":{"name":"ready-callback","version":"2.0.0","description":"Launch server after all async task ready","keywords":["koa","ready","async"],"main":"lib/ready.js","files":["index.js","lib"],"dependencies":{"debug":"^2.6.0","get-ready":"^2.0.0","once":"^1.4.0","uuid":"^3.0.1"},"devDependencies":{"autod":"^2.7.1","egg-bin":"^2.0.2","egg-ci":"^1.1.0","eslint":"^3.15.0","eslint-config-egg":"^3.2.0","koa":"^1.2.4","spy":"^1.0.0"},"repository":{"type":"git","url":"git+https://github.com/node-modules/ready-callback.git"},"homepage":"https://github.com/node-modules/ready-callback","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"autod":"autod","lint":"eslint .","test":"npm run lint -- --fix && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && egg-bin cov"},"engines":{"node":">=4.0.0"},"ci":{"version":"4, 6, 7"},"gitHead":"18efcbb05c25f9b8f9dc23d3714223793b8ae3fd","bugs":{"url":"https://github.com/node-modules/ready-callback/issues"},"_id":"ready-callback@2.0.0","_shasum":"20ec95a3965f4717bd8cd5434f57e7c79001bf95","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"dist":{"shasum":"20ec95a3965f4717bd8cd5434f57e7c79001bf95","size":3179,"noattachment":false,"key":"/ready-callback/-/ready-callback-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ready-callback/download/ready-callback-2.0.0.tgz"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/ready-callback-2.0.0.tgz_1486648179711_0.8211493846029043"},"directories":{},"publish_time":1486648181483,"_cnpm_publish_time":1486648181483,"_hasShrinkwrap":false},"1.0.0":{"name":"ready-callback","version":"1.0.0","description":"Launch server after all async task ready","keywords":["koa","ready","async"],"main":"index.js","files":["index.js","lib"],"dependencies":{"debug":"~2.2.0","extend":"~3.0.0","once":"~1.3.2","get-ready":"~1.0.0","uuid":"~2.0.1"},"devDependencies":{"istanbul":"0","eslint":"1","koa":"1","mocha":"1","should":"6","spy":"0"},"repository":{"type":"git","url":"git+https://github.com/node-modules/ready-callback.git"},"homepage":"https://github.com/node-modules/ready-callback","author":{"name":"popomore","email":"sakura9515@gmail.com"},"license":"MIT","scripts":{"lint":"eslint .","test":"mocha -R spec -t 20000","cov":"npm run lint && istanbul cover --report=none node_modules/mocha/bin/_mocha -- -R spec -t 20000 && istanbul report json html","autod":"autod -e test/fixtures -f ~ -w"},"engines":{"node":">=2.0.0"},"gitHead":"53e87742b3e6f5f2796343ec393851f76e5f7b2a","bugs":{"url":"https://github.com/node-modules/ready-callback/issues"},"_id":"ready-callback@1.0.0","_shasum":"d467e8f65b6cd218a8343f36a31f7024b750293d","_from":".","_npmVersion":"3.3.6","_nodeVersion":"4.2.1","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"dist":{"shasum":"d467e8f65b6cd218a8343f36a31f7024b750293d","size":3095,"noattachment":false,"key":"/ready-callback/-/ready-callback-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ready-callback/download/ready-callback-1.0.0.tgz"},"directories":{},"publish_time":1445355645717,"_cnpm_publish_time":1445355645717,"_hasShrinkwrap":false}},"readme":"# ready-callback\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/ready-callback.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ready-callback\n[travis-image]: https://img.shields.io/travis/node-modules/ready-callback.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/ready-callback\n[codecov-image]: https://codecov.io/github/node-modules/ready-callback/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/node-modules/ready-callback?branch=master\n[david-image]: https://img.shields.io/david/node-modules/ready-callback.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/ready-callback\n[download-image]: https://img.shields.io/npm/dm/ready-callback.svg?style=flat-square\n[download-url]: https://npmjs.org/package/ready-callback\n\nLaunch server after all async task ready\n\n---\n\n## Install\n\n```\n$ npm install ready-callback\n```\n\n## Usage\n\n**Note: ready-callback is using `class`, so you should use node>=2**\n\n```\nvar koa = require('koa');\nvar ready = require('ready-callback')();\nvar app = koa();\nready.mixin(app);\n\n// register a service\nvar done = app.readyCallback('service');\nserviceLaunch(done);\n\n// callback will be fired after all service launched\napp.ready(function() {\n  app.listen();\n});\n```\n\n### Error Handle\n\nIf task is called with error, `error` event will be emit, `ready` will never be called.\n\n```\n// register a service that will emit error\nvar done = app.readyCallback('service');\nserviceLaunch(function(err) {\n  done(err);\n});\n\n// listen error event\napp.on('error', function(err) {\n  // catch error\n});\n```\n\n### Weak Dependency\n\nIf you set a task weak dependency, task will be done without emit `error`.\n\n```\nvar done = app.readyCallback('service', {isWeakDep: true});\nserviceLaunch(function(err) {\n  done(err);\n});\n\n// will be ready\napp.ready(function() {\n  app.listen();\n});\n\napp.on('error', function(err) {\n  // never be called\n});\n```\n\nYou can also set for all ready-callback\n\n```\nvar ready = require('ready-callback')({isWeakDep: true});\n```\n\n### Ready Status\n\nYou can get status every callback end.\n\n```\napp.on('ready_stat', function(data) {\n  console.log(data.id); // id of the ended task\n  console.log(data.remain); // tasks waiting to be ended\n});\n```\n\n### Timeout\n\nYou can set timeout when a task run a long time.\n\n```\nvar ready = require('ready-callback')({timeout: 1000});\nready.mixin(app);\napp.on('ready_timeout', function(id) {\n  // this will be called after 1s that `service` task don't complete\n});\n\nvar done = app.readyCallback('service');\nserviceLaunch(function() {\n  // run a long time\n  done();\n});\n```\n\nYou can also set timeout for every task\n\n```\nready.mixin(app);\napp.on('ready_timeout', function(id) {\n  // this will be called after 1s that `service` task don't complete\n});\n\nvar done = app.readyCallback('service1', {timeout: 1000});\nserviceLaunch(done);\n```\n\n### lazyStart\n\nYou can set a ready-callback object to lazyStart. It will not check \nready status immediately, and should start manualy to check ready \nstatus.\n\n```js\nvar ready = require('ready-callback')({ lazyStart: true });\nyield sleep(1);\n// ready obj is not ready\nready.start();\nyield sleep(1);\n// ready obj is ready now\n```\n\n## LISENCE\n\nCopyright (c) 2015 popomore. Licensed under the MIT license.\n","_attachments":{},"homepage":"https://github.com/node-modules/ready-callback","bugs":{"url":"https://github.com/node-modules/ready-callback/issues"},"license":"MIT"}