{"id":16007291,"url":"https://github.com/jahed/promises","last_synced_at":"2025-03-17T20:31:03.339Z","repository":{"id":57120040,"uuid":"142266321","full_name":"jahed/promises","owner":"jahed","description":"Composable Functions for Promises","archived":false,"fork":false,"pushed_at":"2020-11-06T01:57:27.000Z","size":307,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T18:42:37.579Z","etag":null,"topics":["async","functional-programming","javascript","promise"],"latest_commit_sha":null,"homepage":"https://jahed.github.io/promises/","language":"TypeScript","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/jahed.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}},"created_at":"2018-07-25T07:49:21.000Z","updated_at":"2021-05-17T03:35:41.000Z","dependencies_parsed_at":"2022-08-24T04:31:36.211Z","dependency_job_id":null,"html_url":"https://github.com/jahed/promises","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahed%2Fpromises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahed%2Fpromises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahed%2Fpromises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahed%2Fpromises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jahed","download_url":"https://codeload.github.com/jahed/promises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878494,"owners_count":20362433,"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":["async","functional-programming","javascript","promise"],"created_at":"2024-10-08T12:02:38.141Z","updated_at":"2025-03-17T20:31:02.979Z","avatar_url":"https://github.com/jahed.png","language":"TypeScript","readme":"# @jahed/promises\n\n[![npm](https://img.shields.io/npm/v/@jahed/promises.svg)](https://www.npmjs.com/package/@jahed/promises)\n[![Patreon](https://img.shields.io/badge/patreon-donate-f96854.svg)](https://www.patreon.com/jahed)\n[![Liberapay](https://img.shields.io/badge/liberapay-donate-d9b113.svg)](https://liberapay.com/jahed)\n[![PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://paypal.me/jahed/5)\n\nFunctions for Promises. Use Promises as control flow and worry less about\nwhat's asynchronous and what isn't.\n\nChanging a component from sync to async should not require a large rewrite. By\nusing functions, we can abstract those differences out for a more consistent and\nflexible approach.\n\nThis approach is especially powerful in plain JavaScript where there's no\ntypechecking to ensure you're handling promises correctly. In statically typed\nlanguages like TypeScript, you may prefer the standard async/await syntax as it's\nbuilt into the language and can flag incorrect handling of promises.\n\n### Useful Links\n\n- [Documentation](https://jahed.github.io/promises)\n\n## Installation\n\n```bash\n# Yarn\nyarn add @jahed/promises\n\n# NPM\nnpm install @jahed/promises\n```\n\n## Usage\n\nSee the [documentation](https://jahed.github.io/promises) and\n`src/[function].test.js` for usage examples.\n\nHere's a bigger abstract example using multiple functions together.\n\n```js\nimport {\n  compose,\n  relay,\n  not,\n  branch,\n  waterfall,\n  every,\n  doNothing\n} from '@jahed/promises'\n\nconst setup = waterfall(\n  input =\u003e getEnvironment(input),\n  relay(\n    env =\u003e clear(env),\n    env =\u003e make(env)\n  )\n)\n\nconst doSomething = compose(\n  relay(\n    input =\u003e not(alreadyDidIt(input))\n  ),\n  branch(\n    compose(\n      waterfall(\n        input =\u003e every({\n          input: input,\n          env: setup(input)\n        }),\n        args =\u003e doSomethingBigger(args)\n      ),\n      branch(\n        result =\u003e {\n          console.log('did something big', { result })\n        },\n        error =\u003e {\n          console.error('failed hard.', error)\n          process.exit(1)\n        }\n      )\n    ),\n    doNothing()\n  )\n)\n\ndoSomething('input')\n```\n\n## Contributions\n\nThis package is a work-in-progress and will grow as more needs arise.\n\nIs there a function or use-case you have that's not covered by this package?\nSubmit an issue or pull request with your ideas and let's discuss!\n\n## License\n\nSee `LICENSE` file.\n","funding_links":["https://www.patreon.com/jahed","https://liberapay.com/jahed","https://paypal.me/jahed/5"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahed%2Fpromises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjahed%2Fpromises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahed%2Fpromises/lists"}