{"id":13623649,"url":"https://github.com/NicolasLopes7/ts-async-kit","last_synced_at":"2025-04-15T15:30:35.458Z","repository":{"id":73535838,"uuid":"604935372","full_name":"NicolasLopes7/ts-async-kit","owner":"NicolasLopes7","description":"the easiest API to deal with promises in Typescript. Currently, ↩️ Retrying 🏃‍♂️ looping \u0026 😴 sleeping","archived":false,"fork":false,"pushed_at":"2024-07-03T21:47:39.000Z","size":56,"stargazers_count":41,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T23:41:51.531Z","etag":null,"topics":["async","async-loop","async-sleep","promises","retry","sleep","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NicolasLopes7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-02-22T04:50:59.000Z","updated_at":"2024-07-03T17:41:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba741887-e55a-4628-84ce-1a9b0f3383ce","html_url":"https://github.com/NicolasLopes7/ts-async-kit","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.5263157894736843,"last_synced_commit":"f40bf2420d36594c0847cd1ce38b94e337db03fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasLopes7%2Fts-async-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasLopes7%2Fts-async-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasLopes7%2Fts-async-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasLopes7%2Fts-async-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NicolasLopes7","download_url":"https://codeload.github.com/NicolasLopes7/ts-async-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249097721,"owners_count":21212342,"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","async-loop","async-sleep","promises","retry","sleep","typescript"],"created_at":"2024-08-01T21:01:34.185Z","updated_at":"2025-04-15T15:30:35.190Z","avatar_url":"https://github.com/NicolasLopes7.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\n# 🚀 ts-async-kit\nA lightweight TypeScript library that provides an easy-to-use API for dealing with common promise-related operations such as retrying and looping.\n\n## Installation\nTo install ts-async-kit in your project, simply run:\n\n```sh\npnpm i ts-async-kit\n```\n\n## Usage\n\n### Retry ↩️\nSometimes, a promise may fail due to a temporary issue such as a network error. In such cases, retrying the operation can be a useful strategy. With ts-async-kit, you can easily retry a promise until it succeeds or reaches a maximum number of attempts.\n\nHere's an example:\n\n```ts\nimport { retry } from 'ts-async-kit';\n\nconst fetchData = async () =\u003e {\n  // Fetch data from an API\n};\n\nconst result = await retry(fetchData, { maxRetries: 3 })\n```\n\nIn the above example, fetchData is called up to three times, and the result is logged to the console if successful. If all attempts fail, an error is thrown.\n| Parameter | Description |\n| ------- | ------- |\n| MaxRetries (Optional) | How many times the function will be executed |\n| Interval (Optional) | How long the function should wait to retry it again |\n| Timeout (Optional) | How long the function should wait until stops the function execution (and fail) |\n| backoffFactor (Optional) | How much the interval should increase after each retry |\n| onRetry (Optional) | Callback function that can be called with the error when a function is retried |\n| onFail (Optional) | Callback function that can be called with the error when the function execution finishes by `MaxRetries` OR `Timeout` |\n\n### Sleep 😴 \nSometimes, you just want to block the current flow of execution and wait a certain time. For you don't waste time searching\non StackOverflow, we shipped a function that easily does that. It's called `sleep`.\n\nHere's an example:\n\n```ts\nimport { sleep } from 'ts-async-kit'\n\nawait sleep(1000) // Time in ms to sleep\n```\n\n### Loop (WIP) 🏃‍♂️\nSometimes, you may need to perform a task repeatedly, such as polling an API for updates. With `ts-async-kit`, you can control how your loop will work. Error-tolerant, concurrent operations, until a condition is met, maximum number of iterations and so on...\n\nHere's an example:\n\n```ts\n\nimport { map } from 'ts-async-kit';\n\nconst data = [1, 2, 3]\nconst pollApi = async (id: number) =\u003e {\n  // Poll an API for updates\n};\n\nconst result = await map(data, pollApi, { concurrency: 2 })\n```\nIn the above example, pollApi is called up until it finishes executing two promises concurrently. If all iterations fail, an error is thrown.\n\nContributing\nWe welcome contributions! If you have an idea for a feature or would like to report a bug, please open an issue or submit a pull request.\n\nLicense\n`ts-async-kit` is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNicolasLopes7%2Fts-async-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNicolasLopes7%2Fts-async-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNicolasLopes7%2Fts-async-kit/lists"}