{"_id":"co-assert-timeout","_rev":"377227","name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"modified":"2021-07-31T15:52:13.000Z","created":"2013-11-17T07:52:42.789Z","1.0.0":"2018-08-14T06:49:48.318Z","0.0.5":"2014-09-15T06:02:36.978Z","0.0.4":"2014-03-26T01:00:53.338Z","0.0.3":"2013-12-20T11:26:50.339Z","0.0.2":"2013-11-17T20:16:44.155Z","0.0.1":"2013-11-17T07:52:42.789Z"},"users":{"bhaskarmelkani":true},"author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"repository":{"type":"git","url":"git+https://github.com/cojs/assert-timeout.git"},"versions":{"1.0.0":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"1.0.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/cojs/assert-timeout.git"},"bugs":{"url":"https://github.com/cojs/assert-timeout/issues"},"dependencies":{"co":"^3.1.0","ms":"^2.1.1"},"devDependencies":{"mocha":"^5.2.0","should":"^13.2.3"},"scripts":{"test":"make test"},"engines":{"node":">= 8.0.0"},"gitHead":"5632d0a8f8038afdf9846926f4175ab1e3f91f95","homepage":"https://github.com/cojs/assert-timeout#readme","_id":"co-assert-timeout@1.0.0","_npmVersion":"6.1.0","_nodeVersion":"10.6.0","_npmUser":{"name":"coderhaoxin","email":"haoxins@icloud.com"},"dist":{"shasum":"d3d02b6d372ead26ea31a21d7d434c726cf2b10e","size":2347,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-1.0.0.tgz"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/co-assert-timeout_1.0.0_1534229388274_0.0004580606534301257"},"_hasShrinkwrap":false,"publish_time":1534229388318,"_cnpm_publish_time":1534229388318},"0.0.5":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"0.0.5","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/cojs/assert-timeout.git"},"bugs":{"url":"https://github.com/cojs/assert-timeout/issues"},"dependencies":{"co":"3","ms":"~0.6.2"},"devDependencies":{"mocha":"*","should":"*"},"scripts":{"test":"make test;"},"engines":{"node":">= 0.11.3"},"gitHead":"10dda5306e81a8f0c1f49b643789679d6a62ba4d","homepage":"https://github.com/cojs/assert-timeout","_id":"co-assert-timeout@0.0.5","_shasum":"d2e5045dfba9d1a415d851d6aaeec7514b6d13df","_from":".","_npmVersion":"1.4.26","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"dist":{"shasum":"d2e5045dfba9d1a415d851d6aaeec7514b6d13df","size":2404,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-0.0.5.tgz"},"directories":{},"publish_time":1410760956978,"_cnpm_publish_time":1410760956978,"_hasShrinkwrap":false},"0.0.4":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"0.0.4","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/cojs/assert-timeout.git"},"bugs":{"url":"https://github.com/cojs/assert-timeout/issues"},"dependencies":{"co":"~3.0.4","ms":"~0.6.2"},"devDependencies":{"mocha":"*","should":"*"},"scripts":{"test":"make test;"},"engines":{"node":">= 0.11.3"},"homepage":"https://github.com/cojs/assert-timeout","_id":"co-assert-timeout@0.0.4","dist":{"shasum":"b1c86bc9c62ca60ad53d8f6905f2a91158d1fffe","size":2408,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-0.0.4.tgz"},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"publish_time":1395795653338,"_hasShrinkwrap":false,"_cnpm_publish_time":1395795653338},"0.0.3":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"0.0.3","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/funraiseme/simgr.git"},"bugs":{"url":"https://github.com/funraiseme/simgr/issues"},"dependencies":{"ms":"~0.6.1"},"devDependencies":{"co":">= 3.0.1","mocha":"*","should":"*"},"scripts":{"test":"make test;"},"engines":{"node":">= 0.11.3"},"homepage":"https://github.com/funraiseme/simgr","_id":"co-assert-timeout@0.0.3","dist":{"shasum":"9701fdc7df95266d7d927de3d844398f51aabb4a","size":2425,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-0.0.3.tgz"},"_from":".","_npmVersion":"1.3.18","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"publish_time":1387538810339,"_hasShrinkwrap":false,"_cnpm_publish_time":1387538810339},"0.0.2":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"0.0.2","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/funraiseme/simgr.git"},"bugs":{"url":"https://github.com/funraiseme/simgr/issues"},"dependencies":{"ms":"~0.6.1","co":"~2.3.0"},"devDependencies":{"mocha":"*","should":"*"},"scripts":{"test":"make test;"},"engines":{"node":">= 0.11.3"},"homepage":"https://github.com/funraiseme/simgr","_id":"co-assert-timeout@0.0.2","dist":{"shasum":"515c48beffeeb9a63f87f5807a692a31227c789a","size":2443,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"publish_time":1384719404155,"_hasShrinkwrap":false,"_cnpm_publish_time":1384719404155},"0.0.1":{"name":"co-assert-timeout","description":"Assert a thunk or generator's timeout co-style","version":"0.0.1","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/funraiseme/simgr.git"},"bugs":{"url":"https://github.com/funraiseme/simgr/issues"},"dependencies":{"ms":"~0.6.1","co":"~2.3.0"},"devDependencies":{"mocha":"*","should":"*"},"scripts":{"test":"make test;"},"engines":{"node":">= 0.11.3"},"homepage":"https://github.com/funraiseme/simgr","_id":"co-assert-timeout@0.0.1","dist":{"shasum":"e01c1befd37cb2eeb24dd62d4c710eae8642a9c7","size":2394,"noattachment":false,"key":"/co-assert-timeout/-/co-assert-timeout-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/co-assert-timeout/download/co-assert-timeout-0.0.1.tgz"},"_from":".","_npmVersion":"1.3.13","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"publish_time":1384674762789,"_hasShrinkwrap":false,"_cnpm_publish_time":1384674762789}},"readme":"# Co Assert Timeout [![Build Status](https://travis-ci.org/cojs/assert-timeout.png)](https://travis-ci.org/cojs/assert-timeout)\n\nAssert that a thunk or generator takes less than a certain amount of time.\nNote that it does not stop the thunk or generator from finish executing.\n\n## Examples\n\n### Koa\n\nTo set the timeout of all the downstream middleware, you can do the following:\n\n```js\napp.use(function* (next) {\n  yield assertTimeout(next, '5 seconds')\n})\n```\n\nHowever, you generally don't want to do this.\nYou only want to set a timeout when the client takes too long to do something,\nnot you.\nSpecifically, you should set a timeout only on the client sending a request:\n\n```js\napp.use(function* (next) {\n  var buffer = yield assertTimeout(this.request.buffer(), '5 seconds')\n})\n```\n\nIf you want to customize or handle the error yourself:\n\n```js\napp.use(function* (next) {\n  try {\n    var buffer = yield assertTimeout(this.request.buffer(), '5 seconds')\n  } catch (err) {\n    if (err.status === 408) {\n      // assertTimeout's errors will have err.status = 408\n      // let's make a new error with a custom message\n      err = new Error('you took too long to upload')\n      err.status = 408\n    }\n\n    // rethrow the error\n    throw err\n  }\n\n  yield next\n})\n```\n\n## API\n\n### assertTimeout(fn, timeout, [done])\n\n- `fn` - a thunk, generator, or generator function\n- `timeout` - timeout in milliseconds integer or a string\n- `done` - optional callback called only when `fn` finishes executing after the timeout error is thrown\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_attachments":{},"homepage":"https://github.com/cojs/assert-timeout#readme","bugs":{"url":"https://github.com/cojs/assert-timeout/issues"},"license":"MIT"}