{"id":15287005,"url":"https://github.com/myty/promise-chain","last_synced_at":"2026-01-22T07:03:59.534Z","repository":{"id":58600805,"uuid":"532349589","full_name":"myty/promise-chain","owner":"myty","description":"Utility class to wrap classes that are meant for method chaining, specifically useful for functions that return Promises. Promise functions and non-promise functions can be mixed.","archived":false,"fork":false,"pushed_at":"2024-05-14T03:16:51.000Z","size":69,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-12T22:58:27.036Z","etag":null,"topics":["deno","hacktoberfest","typescript"],"latest_commit_sha":null,"homepage":"","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/myty.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,"zenodo":null}},"created_at":"2022-09-03T19:01:18.000Z","updated_at":"2024-05-14T03:16:12.000Z","dependencies_parsed_at":"2025-04-13T04:12:20.773Z","dependency_job_id":"794c0558-5a8a-441d-b6fd-c082fadd1b36","html_url":"https://github.com/myty/promise-chain","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"e7e0e0c5c4225e0311c660f5eeba285276824cd3"},"previous_names":["myty/composable-async","myty/composable-promise"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/myty/promise-chain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fpromise-chain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fpromise-chain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fpromise-chain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fpromise-chain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myty","download_url":"https://codeload.github.com/myty/promise-chain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myty%2Fpromise-chain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["deno","hacktoberfest","typescript"],"created_at":"2024-09-30T15:20:16.416Z","updated_at":"2026-01-22T07:03:59.506Z","avatar_url":"https://github.com/myty.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PromiseChain\n\n[![JSR](https://jsr.io/badges/@myty/promise-chain)](https://jsr.io/@myty/promise-chain)\n[![JSR Score](https://jsr.io/badges/@myty/promise-chain/score)](https://jsr.io/@myty/promise-chain)\n[![GitHub version](https://badgen.net/github/release/myty/promise-chain?color=green)](https://github.com/myty/promise-chain)\n[![deno land](https://badgen.net/github/release/myty/promise-chain?color=green\u0026label=deno.land)](https://deno.land/x/promise_chain)\n[![npm version](https://badgen.net/npm/v/@myty/promise-chain?color=green)](https://www.npmjs.com/package/@myty/promise-chain)\n[![Coverage Status](https://badgen.net/coveralls/c/github/myty/promise-chain?color=green)](https://coveralls.io/github/myty/promise-chain?branch=main)\n\nWrapper utility class that enables composition via asynchronous (Promises) and\nsynchronous method chaining.\n\n## Installation\n\n### Node.js\n\n```bash\n# npm\nnpm install --save promise-chain\n# yarn\nyarn add promise-chain\n# pnpm\npnpm install --save promise-chain\n```\n\n### Deno\n\n```bash\nimport Composable from \"https://deno.land/x/promise_chain/mod.ts\";\n```\n\n## Example Usage\n\nProvided the following class:\n\n```typescript\nclass TestClass {\n  public readonly propertyOne: number;\n  public readonly propertyTwo: number;\n\n  constructor({\n    propertyOne = 0,\n    propertyTwo = 0,\n  }: Partial\u003cTestClass\u003e = {}) {\n    this.propertyOne = propertyOne;\n    this.propertyTwo = propertyTwo;\n  }\n\n  async asyncIncrement(\n    property: string,\n    increment: number,\n  ): Promise\u003cTestClass\u003e {\n    return new TestClass({\n      ...this,\n      [property]: await Promise.resolve(this[property] + increment),\n    });\n  }\n\n  increment(\n    property: string,\n    increment: number,\n  ): Promise\u003cTestClass\u003e {\n    return new TestClass({\n      ...this,\n      [property]: this[property] + increment,\n    });\n  }\n}\n```\n\nTraditionally to chain these methods you would need to do the follwing:\n\n```typescript\nconst { propertyOne, propertyTwo } = await testClass\n  .asyncIncrement(\"propertyOne\", 3)\n  .then((t) =\u003e t.asyncIncrement(\"propertyTwo\", 5))\n  .then((t) =\u003e Promise.resolve(t.increment(\"propertyTwo\", 5)));\n\nconsole.log(`Result: propertyOne=${propertyOne}, propertyTwo=${propertyTwo}`);\n// OUTPUT: \"Result: propertyOne=3, propertyTwo=10\"\n```\n\nWith PromiseChain, it is simplified and easier to read.\n\n```typescript\nconst { propertyOne, propertyTwo } = await PromiseChain(testClass)\n  .asyncIncrement(\"propertyOne\", 3)\n  .asyncIncrement(\"propertyTwo\", 5)\n  .increment(\"propertyTwo\", 5);\n\nconsole.log(`Result: propertyOne=${propertyOne}, propertyTwo=${propertyTwo}`);\n// OUTPUT: \"Result: propertyOne=3, propertyTwo=10\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fpromise-chain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyty%2Fpromise-chain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyty%2Fpromise-chain/lists"}