{"id":17398471,"url":"https://github.com/vweevers/catering","last_synced_at":"2025-04-30T06:44:33.255Z","repository":{"id":32937546,"uuid":"146982585","full_name":"vweevers/catering","owner":"vweevers","description":"Simple utility to allow your module to be consumed with a callback or promise.","archived":false,"fork":false,"pushed_at":"2023-11-01T07:42:44.000Z","size":21,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T06:44:28.715Z","etag":null,"topics":["callback","nodejs","npm-package","promise"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-01T08:44:33.000Z","updated_at":"2023-12-10T14:49:54.000Z","dependencies_parsed_at":"2024-06-18T18:30:29.016Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/catering","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":0.2857142857142857,"last_synced_commit":"e2ea7719bae98efc7479fd86b2b27f48d6cb0d95"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fcatering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fcatering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fcatering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fcatering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/catering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251658196,"owners_count":21622819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["callback","nodejs","npm-package","promise"],"created_at":"2024-10-16T14:57:03.852Z","updated_at":"2025-04-30T06:44:33.235Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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\u0026logoColor=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(() =\u003e 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) =\u003e {})\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fcatering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fcatering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fcatering/lists"}