{"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":{"integrity":"sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==","shasum":"66acba06ed5ee28d5286133982a927de9a04b510","tarball":"http://registry-npm.ywwl.com/catering/download/catering-2.1.1.tgz","fileCount":7,"unpackedSize":5001,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh4T5ACRA9TVsSAnZWagAAtYoP/3xr5qj71Xtw6wWs9YSh\npifnd9rB6JJkyOsZnDRZHsRBG5FP7LJoa693zWUtNZDBhKaG0P4ucAN+r+FA\nRm3Di3tvXDiGdH52M2kAz4g56xNAb24oq48A0fDs069liU5mN6721yjcVX/s\ndRrLYzi7lEhiAHhxDGj9jEmLu7KdvH6WZDwrcdtCuAr6cbl9rLtK7TPFNi0w\n71otoA1xBeJd1LvWtzvadP/sWF7qSqHmC0P7eNvb3uvXIIKmMVUR+UCR3hAF\nvyzf+LUYRCcd38m4OPlfy46DtZ8FP63UoIW4ceah+E3jLCDE+kDaAI3AzWsu\nZm9/J3gRcsrBNw7ad8GX4I5GjTfXbpwGpUUlDmo3eTkGsHM9pH/H+XqJOFhc\nM9lZ+Poi8XGsF/LFqpqPVHjM1TtTP0jQR5gKP90WJCeQNaAdzSwiWzgtu6XJ\ndihLoCYcIXFgH0tQnQHzcyKCRkZwj27VDh2PIw/tffAytHPGfe63Lhv9rhBg\nN9z20+mf9H7eU0sc2Qcfhxr0pA8LFaDfTuCSeSMNgCO70FtvjqW9lfF6c0HI\nsCUnbr6aVWXplUaVzIu256pbEw0OF7oNVbIYf8opH9sezynZFtlfAevSNuaq\nTiemG0vdeuXt8dMDwulDO7NeYDMiBcrjMNPhirY2ENDfykzr8v5cNmazZT/t\nt2jW\r\n=19GF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICZNd0gZJS6Ow6cjthuQsTjtNP2XQoiFKVzpth6uyo9gAiEAxXJYK5J2ZJDWKGsNDMu+Hp2j3EtgujBFDk7a8OCdCrY="}],"size":2417,"noattachment":false,"key":"/catering/-/catering-2.1.1.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":"dev@vincentweevers.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catering_2.1.1_1642151488579_0.8179611008071046"},"_hasShrinkwrap":false,"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](https://img.shields.io/npm/v/catering.svg)](https://www.npmjs.com/package/catering)\n[![Node version](https://img.shields.io/node/v/catering.svg)](https://www.npmjs.com/package/catering)\n[![Test](https://img.shields.io/github/workflow/status/vweevers/catering/Test?label=test)](https://github.com/vweevers/catering/actions/workflows/test.yml)\n[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript&logoColor=fff)](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","publish_time":1642151488750,"_cnpm_publish_time":1642151488750,"dist-tags":{"latest":"2.1.1"}}