{"id":19817689,"url":"https://github.com/msaaddev/promise-it","last_synced_at":"2025-05-01T11:31:01.712Z","repository":{"id":39653314,"uuid":"494917105","full_name":"msaaddev/promise-it","owner":"msaaddev","description":"A simple Node.js package that helps you not to look up JavaScript promise syntax every time you use it.","archived":false,"fork":false,"pushed_at":"2022-05-29T09:30:34.000Z","size":248,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-31T18:37:02.565Z","etag":null,"topics":["nodejs-promise","promise","promisify"],"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/msaaddev.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-21T23:34:24.000Z","updated_at":"2024-01-24T15:49:58.000Z","dependencies_parsed_at":"2022-09-19T06:30:52.599Z","dependency_job_id":null,"html_url":"https://github.com/msaaddev/promise-it","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaaddev%2Fpromise-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaaddev%2Fpromise-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaaddev%2Fpromise-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaaddev%2Fpromise-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msaaddev","download_url":"https://codeload.github.com/msaaddev/promise-it/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224253335,"owners_count":17280934,"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":["nodejs-promise","promise","promisify"],"created_at":"2024-11-12T10:13:20.936Z","updated_at":"2024-11-12T10:13:21.648Z","avatar_url":"https://github.com/msaaddev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![cover](assets/cover.png)\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"https://img.shields.io/npm/v/@msaaddev/promise-it?color=%230F2345\" alt=\"version\"\u003e\n\t\u003cimg src=\"https://img.shields.io/npm/l/@msaaddev/promise-it?color=%230F2345\" alt=\"license\"\u003e\n\t\u003cimg src=\"https://img.shields.io/npm/dt/@msaaddev/promise-it?color=%23222F4C\" alt=\"downloads\"\u003e\n\t\u003ca href=\"https://stars.github.com/nominate/\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/GitHub%20Star-Nominate%20%40msaaddev-%230F2345\" alt=\"nominate @msaaddev for GitHub Star\" /\u003e\n\t\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003eA simple Node.js package that helps you not to look up JavaScript promise syntax every time you use it.\u003c/strong\u003e\n\u003c/p\u003e\n\n![separator](assets/separator.jpeg)\n\n-   **Simple**: Adds abstraction to the promise syntax\n-   **Easy to use**: No need to learn JavaScript promise syntax\n-   **Promise**: Turns any function into a promise\n-   **All promises**: Provides a way to chain all promises and returns the result collectively\n-   **Any promise**: Takes array of promise and returns a promise that resolves when any of the promise is resolved\n-   **All settled promises**: Takes array of promise and returns a promise that resolves when all promises are settled\n\n\u003cbr\u003e\n\n\u003cimg src=\"./assets/suitcase.png\" width=\"10%\" /\u003e\n\n## Install\n\n```sh\n# install the package\nnpm install @msaaddev/promise-it\n```\n\n\u003cbr\u003e\n\n\u003cimg src=\"./assets/api.png\" width=\"10%\" /\u003e\n\n## API\n\n#### promiseIt()\n\nPromisify a callback function\n\n#### promiseItAll()\n\nCreates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.\n\n#### promiseItAny()\n\nPromisify any of the given callback functions\n\n#### promiseItAllSettled()\n\nCreates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.\n\n\u003cbr\u003e\n\n\u003cimg src=\"./assets/rocket.png\" width=\"10%\" /\u003e\n\n## Usage\n\n-   promiseIt()\n\n```js\nconst { promiseIt } = require('@msaaddev/promise-it');\n\n(async () =\u003e {\n\tconst callback = (resolve, reject) =\u003e {\n\t\texec(`networkQuality`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\thandleError(error);\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality.');\n\t\t});\n\t};\n\n\ttry {\n\t\tconst promise = await promiseIt(callback);\n\t\tconsole.log(promise);\n\t} catch (err) {\n\t\tconsole.log(err);\n\t}\n})();\n```\n\n-   promiseItAll()\n\n```js\nconst { promiseItAll } = require('@msaaddev/promise-it');\nconst { exec } = require('child_process');\n\n(async () =\u003e {\n\tconst callback = (resolve, reject) =\u003e {\n\t\texec(`networkQuality`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\thandleError(error);\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality.');\n\t\t});\n\t};\n\n\tconst callback2 = (resolve, reject) =\u003e {\n\t\texec(`networkQuality -v`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality -v.');\n\t\t});\n\t};\n\n\ttry {\n\t\tconst allPromises = await promiseItAll(callback, callback2);\n\t\tconsole.log(allPromises);\n\t} catch (err) {\n\t\tconsole.log(err);\n\t}\n})();\n```\n\n-   promiseItAny()\n\n```js\nconst { promiseItAny } = require('@msaaddev/promise-it');\nconst { exec } = require('child_process');\n\n(async () =\u003e {\n\tconst callback = (resolve, reject) =\u003e {\n\t\texec(`networkQuality`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\thandleError(error);\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality.');\n\t\t});\n\t};\n\n\tconst callback2 = (resolve, reject) =\u003e {\n\t\texec(`networkQuality -v`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality -v.');\n\t\t});\n\t};\n\n\ttry {\n\t\tconst anyPromise = await promiseItAny(callback, callback2);\n\t\tconsole.log(anyPromise);\n\t} catch (err) {\n\t\tconsole.log(err);\n\t}\n})();\n```\n\n-   promiseItAllSettled()\n\n```js\nconst { promiseItAllSettled } = require('@msaaddev/promise-it');\nconst { exec } = require('child_process');\n\nconst { promiseIt, promiseItAll, promiseItAny } = require('./index');\nconst { exec } = require('child_process');\n\n(async () =\u003e {\n\tconst callback = (resolve, reject) =\u003e {\n\t\texec(`networkQuality`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\thandleError(error);\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality.');\n\t\t});\n\t};\n\n\tconst callback2 = (resolve, reject) =\u003e {\n\t\texec(`networkQuality -v`, error =\u003e {\n\t\t\tif (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t\tresolve('All good. Ran networkQuality -v.');\n\t\t});\n\t};\n\n\ttry {\n\t\tconst allSettledPromise = await promiseItAllSettled(\n\t\t\tcallback,\n\t\t\tcallback2\n\t\t);\n\t\tconsole.log(allSettledPromise);\n\t} catch (err) {\n\t\tconsole.log(err);\n\t}\n})();\n```\n\n## 👨🏻‍💻 Contributing\n\nMake sure you read the [contributing guidelines](https://github.com/msaaddev/new-tailwind-app/blob/master/contributing.md) before opening a PR.\n\n## ⚡️ Other Projects\n\nI have curated a [detailed list](https://github.com/msaaddev/open-source) of all the open-source projects I have authored. Do take out a moment and take a look.\n\n## 🔑 License \u0026 Conduct\n\n-   MIT © [Saad Irfan](https://github.com/msaaddev)\n-   [Code of Conduct](https://github.com/msaaddev/new-tailwind-app/blob/master/code-of-conduct.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaaddev%2Fpromise-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsaaddev%2Fpromise-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaaddev%2Fpromise-it/lists"}