{"id":13566914,"url":"https://github.com/gcanti/retry-ts","last_synced_at":"2025-04-05T06:06:29.984Z","repository":{"id":32689967,"uuid":"139423612","full_name":"gcanti/retry-ts","owner":"gcanti","description":"Retry combinators for monadic actions that may fail","archived":false,"fork":false,"pushed_at":"2022-04-05T08:14:04.000Z","size":363,"stargazers_count":168,"open_issues_count":1,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-12T22:55:30.034Z","etag":null,"topics":["fp-ts","functional-programming","typescript"],"latest_commit_sha":null,"homepage":"https://gcanti.github.io/retry-ts/","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/gcanti.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-02T09:48:01.000Z","updated_at":"2024-09-16T16:30:30.000Z","dependencies_parsed_at":"2022-08-05T15:30:39.746Z","dependency_job_id":null,"html_url":"https://github.com/gcanti/retry-ts","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcanti%2Fretry-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcanti%2Fretry-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcanti%2Fretry-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcanti%2Fretry-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gcanti","download_url":"https://codeload.github.com/gcanti/retry-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294536,"owners_count":20915340,"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":["fp-ts","functional-programming","typescript"],"created_at":"2024-08-01T13:02:19.479Z","updated_at":"2025-04-05T06:06:29.950Z","avatar_url":"https://github.com/gcanti.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Domain modeling in TypeScript by Benoit Ruiz"],"sub_categories":[],"readme":"TypeScript port of PureScript's [purescript-aff-retry](https://github.com/Unisay/purescript-aff-retry) package\nwhich in turn is a porting of Haskell's [retry](https://github.com/Soostone/retry) package\n\n# Example\n\n```ts\nimport { log } from 'fp-ts/Console'\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as O from 'fp-ts/Option'\nimport * as TE from 'fp-ts/TaskEither'\nimport { capDelay, exponentialBackoff, limitRetries, Monoid, RetryStatus } from 'retry-ts'\nimport { retrying } from 'retry-ts/Task'\n\nconst policy = capDelay(2000, Monoid.concat(exponentialBackoff(200), limitRetries(5)))\n\nconst fakeAPI = TE.left('API errored out')\n\nconst logDelay = (status: RetryStatus) =\u003e\n  TE.rightIO(\n    log(\n      pipe(\n        status.previousDelay,\n        O.map((delay) =\u003e `retrying in ${delay} milliseconds...`),\n        O.getOrElse(() =\u003e 'first attempt...')\n      )\n    )\n  )\n\nconst result = retrying(policy, (status) =\u003e pipe(logDelay(status), TE.apSecond(fakeAPI)), E.isLeft)\n\nresult().then((e) =\u003e console.log(e))\n/*\nfirst attempt...\nretrying in 200 milliseconds...  \u003c= exponentialBackoff\nretrying in 400 milliseconds...  \u003c= exponentialBackoff\nretrying in 800 milliseconds...  \u003c= exponentialBackoff\nretrying in 1600 milliseconds... \u003c= exponentialBackoff\nretrying in 2000 milliseconds... \u003c= exponentialBackoff + capDelay\nleft(\"API errored out\")          \u003c= limitRetries\n*/\n```\n\n# Documentation\n\n- [API Reference](https://gcanti.github.io/retry-ts)\n\n# License\n\nThe MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcanti%2Fretry-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgcanti%2Fretry-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcanti%2Fretry-ts/lists"}