{"_id":"catering","_rev":"2371390","name":"catering","description":"Simple utility to allow your module to be consumed with a callback or promise","dist-tags":{"latest":"2.1.1"},"maintainers":[{"name":"vweevers","email":""}],"time":{"modified":"2022-01-14T09:21:19.000Z","created":"2018-09-01T09:54:45.956Z","2.1.1":"2022-01-14T09:11:28.750Z","2.1.0":"2021-10-02T22:58:36.346Z","2.0.0":"2020-03-27T10:37:37.871Z","1.0.0":"2018-09-01T09:54:45.956Z"},"users":{},"author":{"name":"Vincent Weevers"},"repository":{"type":"git","url":"git+https://github.com/vweevers/catering.git"},"versions":{"2.1.1":{"name":"catering","version":"2.1.1","description":"Simple utility to allow your module to be consumed with a callback or promise","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && node test.js","test-browsers-local":"airtap test.js"},"types":"index.d.ts","browser":{"./next-tick.js":"./next-tick-browser.js"},"devDependencies":{"airtap":"^4.0.4","airtap-playwright":"^1.0.1","standard":"^16.0.4","tape":"^5.4.0"},"keywords":["callback","promise","promisify"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/catering.git"},"bugs":{"url":"https://github.com/vweevers/catering/issues"},"homepage":"https://github.com/vweevers/catering","gitHead":"48fe5fc47c44c9fc9ab76ebd855d8a7ff8f1768a","_id":"catering@2.1.1","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"shasum":"66acba06ed5ee28d5286133982a927de9a04b510","size":2417,"noattachment":false,"key":"/catering/-/catering-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/catering/download/catering-2.1.1.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catering_2.1.1_1642151488579_0.8179611008071046"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-01-14T09:17:04.910Z","publish_time":1642151488750,"_cnpm_publish_time":1642151488750},"2.1.0":{"name":"catering","version":"2.1.0","description":"Simple utility to allow your module to be consumed with a callback or promise","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && node test.js"},"types":"index.d.ts","dependencies":{"queue-tick":"^1.0.0"},"devDependencies":{"standard":"^14.0.0","tape":"^5.0.0"},"keywords":["callback","promise","promisify"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/catering.git"},"bugs":{"url":"https://github.com/vweevers/catering/issues"},"homepage":"https://github.com/vweevers/catering","gitHead":"4aea5492e433d615b700850bcd0d82ac703fab04","_id":"catering@2.1.0","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"shasum":"1354f5e8e231a5b80309302bb23b40624d3212c5","size":2273,"noattachment":false,"key":"/catering/-/catering-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/catering/download/catering-2.1.0.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catering_2.1.0_1633215516232_0.3418503251640026"},"_hasShrinkwrap":false,"publish_time":1633215516346,"_cnpm_publish_time":1633215516346},"2.0.0":{"name":"catering","version":"2.0.0","description":"Simple utility to allow your module to be consumed with a callback or promise","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && node test.js"},"dependencies":{},"devDependencies":{"standard":"^14.0.0","tape":"^4.10.1"},"keywords":["callback","promise","promisify"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/catering.git"},"bugs":{"url":"https://github.com/vweevers/catering/issues"},"homepage":"https://github.com/vweevers/catering","gitHead":"aa67ab87ae7f0baf55bba315f3dd6bc33edbad2f","_id":"catering@2.0.0","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"name":"vweevers","email":""}],"dist":{"shasum":"15ce31bcbffafbf62855ea7677b0e5d23581233d","size":2016,"noattachment":false,"key":"/catering/-/catering-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/catering/download/catering-2.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catering_2.0.0_1585305457707_0.5765510164369574"},"_hasShrinkwrap":false,"publish_time":1585305457871,"_cnpm_publish_time":1585305457871},"1.0.0":{"name":"catering","version":"1.0.0","description":"Cater to callback and promise crowds, internally use callbacks.","license":"MIT","author":{"name":"Vincent Weevers"},"scripts":{"test":"standard && node test.js"},"dependencies":{},"devDependencies":{"standard":"~12.0.1","tape":"~4.9.1"},"keywords":["callback","promise","promisify"],"engines":{"node":">=6"},"repository":{"type":"git","url":"git+https://github.com/vweevers/catering.git"},"bugs":{"url":"https://github.com/vweevers/catering/issues"},"homepage":"https://github.com/vweevers/catering","gitHead":"89c9e3df2ce13d0ae7ab72fa59d7bda7e803c59d","_id":"catering@1.0.0","_shasum":"177f69586fbd21fd5d117c529eea288b0fe433ae","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.0","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"name":"vweevers","email":""}],"dist":{"shasum":"177f69586fbd21fd5d117c529eea288b0fe433ae","size":1963,"noattachment":false,"key":"/catering/-/catering-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/catering/download/catering-1.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catering_1.0.0_1535795685819_0.3280874203749493"},"_hasShrinkwrap":false,"publish_time":1535795685956,"_cnpm_publish_time":1535795685956}},"readme":"# catering\n\n**Cater to callback and promise crowds.**  \nSimple utility to allow your module to be consumed with a callback or promise. For Node.js and browsers.\n\n[![npm status](http://img.shields.io/npm/v/catering.svg)](https://www.npmjs.org/package/catering)\n[![node](https://img.shields.io/node/v/catering.svg)](https://www.npmjs.org/package/catering)\n[![Travis build status](https://img.shields.io/travis/vweevers/catering.svg?label=travis)](http://travis-ci.org/vweevers/catering)\n[![AppVeyor build status](https://img.shields.io/appveyor/ci/vweevers/catering.svg?label=appveyor)](https://ci.appveyor.com/project/vweevers/catering)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Menu\n\nIf your module internally uses callbacks:\n\n```js\nconst { fromCallback } = require('catering')\nconst kPromise = Symbol('promise')\n\nmodule.exports = function (callback) {\n  callback = fromCallback(callback, kPromise)\n  queueMicrotask(() => callback(null, 'example'))\n  return callback[kPromise]\n}\n```\n\nIf your module internally uses promises:\n\n```js\nconst { fromPromise } = require('catering')\n\nmodule.exports = function (callback) {\n  return fromPromise(Promise.resolve('example'), callback)\n}\n```\n\nEither way your module can now be consumed in two ways:\n\n```js\nexample((err, result) => {})\nconst result = await example()\n```\n\nWhen converting from a promise to a callback, `fromPromise` calls the callback in a next tick to escape the promise chain and not let it steal your beautiful errors.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install catering\n```\n\n## License\n\n[MIT](LICENSE) © 2018-present Vincent Weevers. Originally extracted from [`levelup`](https://github.com/Level/levelup/blob/37e0270c8c29d5086904e29e247e918dddcce6e2/lib/promisify.js).\n","_attachments":{},"homepage":"https://github.com/vweevers/catering","bugs":{"url":"https://github.com/vweevers/catering/issues"},"license":"MIT"}