{"id":13493393,"url":"https://github.com/mikehall314/es6-promisify","last_synced_at":"2025-05-14T18:03:01.660Z","repository":{"id":16060774,"uuid":"18805001","full_name":"mikehall314/es6-promisify","owner":"mikehall314","description":"Convert callback-based javascript to ES6 Promises","archived":false,"fork":false,"pushed_at":"2023-03-04T02:31:56.000Z","size":559,"stargazers_count":525,"open_issues_count":3,"forks_count":32,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-01T09:09:04.785Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mikehall314.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}},"created_at":"2014-04-15T15:23:48.000Z","updated_at":"2025-02-22T20:35:54.000Z","dependencies_parsed_at":"2024-01-16T09:36:53.249Z","dependency_job_id":"42cef06e-2c12-4099-a480-4d8b4ee53274","html_url":"https://github.com/mikehall314/es6-promisify","commit_stats":{"total_commits":95,"total_committers":11,"mean_commits":8.636363636363637,"dds":0.631578947368421,"last_synced_commit":"0212402c8756c020cddc3fcf331e6c1e288d0eb0"},"previous_names":["digitaldesignlabs/es6-promisify"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikehall314%2Fes6-promisify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikehall314%2Fes6-promisify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikehall314%2Fes6-promisify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikehall314%2Fes6-promisify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikehall314","download_url":"https://codeload.github.com/mikehall314/es6-promisify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253692536,"owners_count":21948317,"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":[],"created_at":"2024-07-31T19:01:14.790Z","updated_at":"2025-05-14T18:02:56.627Z","avatar_url":"https://github.com/mikehall314.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![Build Status](https://github.com/digitaldesignlabs/es6-promisify/actions/workflows/test.yml/badge.svg)\n\n# es6-promisify\n\nConverts callback-based functions to Promises, using a boilerplate callback function.\n\n## Install\n\nInstall with [npm](https://npmjs.org/package/es6-promisify)\n\n```bash\nnpm install es6-promisify\n```\n\n## Example\n\n```js\nconst {promisify} = require(\"es6-promisify\");\n\n// Convert the stat function\nconst fs = require(\"fs\");\nconst stat = promisify(fs.stat);\n\n// Now usable as a promise!\ntry {\n    const stats = await stat(\"example.txt\");\n    console.log(\"Got stats\", stats);\n} catch (err) {\n    console.error(\"Yikes!\", err);\n}\n```\n\n## Promisify methods\n\n```js\nconst {promisify} = require(\"es6-promisify\");\n\n// Create a promise-based version of send_command\nconst redis = require(\"redis\").createClient(6379, \"localhost\");\nconst client = promisify(redis.send_command.bind(redis));\n\n// Send commands to redis and get a promise back\ntry {\n    const pong = await client.ping();\n    console.log(\"Got\", pong);\n} catch (err) {\n    console.error(\"Unexpected error\", err);\n} finally {\n    redis.quit();\n}\n```\n\n## Handle multiple callback arguments, with named parameters\n\n```js\nconst {promisify} = require(\"es6-promisify\");\n\nfunction test(cb) {\n    return cb(undefined, 1, 2, 3);\n}\n\n// Create promise-based version of test\ntest[promisify.argumentNames] = [\"one\", \"two\", \"three\"];\nconst multi = promisify(test);\n\n// Returns named arguments\nconst result = await multi();\nconsole.log(result); // {one: 1, two: 2, three: 3}\n```\n\n## Provide your own Promise implementation\n\n```js\nconst {promisify} = require(\"es6-promisify\");\n\n// Now uses Bluebird\npromisify.Promise = require(\"bluebird\");\n\nconst test = promisify(cb =\u003e cb(undefined, \"test\"));\nconst result = await test();\nconsole.log(result); // \"test\", resolved using Bluebird\n```\n\n### Tests\n\nTest with tape\n\n```bash\n$ npm test\n```\n\nPublished under the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikehall314%2Fes6-promisify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikehall314%2Fes6-promisify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikehall314%2Fes6-promisify/lists"}