{"id":24416726,"url":"https://github.com/sha1n/about-time","last_synced_at":"2026-04-02T23:57:59.756Z","repository":{"id":41965943,"uuid":"449071938","full_name":"sha1n/about-time","owner":"sha1n","description":"A set of essential time related utilities","archived":false,"fork":false,"pushed_at":"2026-01-17T19:35:27.000Z","size":1567,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-18T03:41:39.956Z","etag":null,"topics":["delay","exponential-backoff","retry","sleep","time","timeout","typescript","utilities"],"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/sha1n.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-01-17T22:53:25.000Z","updated_at":"2026-01-01T11:45:49.000Z","dependencies_parsed_at":"2023-02-18T14:45:22.208Z","dependency_job_id":"c9339b5d-c6d3-409b-be01-cb2f594c8df6","html_url":"https://github.com/sha1n/about-time","commit_stats":{"total_commits":75,"total_committers":2,"mean_commits":37.5,"dds":"0.45333333333333337","last_synced_commit":"764d119a3d834a2623579c4dfd49b9647858fcf8"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/sha1n/about-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Fabout-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Fabout-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Fabout-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Fabout-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sha1n","download_url":"https://codeload.github.com/sha1n/about-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Fabout-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28824115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T18:44:20.126Z","status":"ssl_error","status_checked_at":"2026-01-27T18:44:09.161Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["delay","exponential-backoff","retry","sleep","time","timeout","typescript","utilities"],"created_at":"2025-01-20T08:14:10.175Z","updated_at":"2026-01-27T22:19:30.405Z","avatar_url":"https://github.com/sha1n.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/sha1n/about-time/actions/workflows/ci.yml/badge.svg)](https://github.com/sha1n/about-time/actions/workflows/ci.yml)\n[![Coverage](https://github.com/sha1n/about-time/actions/workflows/coverage.yml/badge.svg)](https://github.com/sha1n/about-time/actions/workflows/coverage.yml)\n![GitHub](https://img.shields.io/github/license/sha1n/about-time)\n![npm type definitions](https://img.shields.io/npm/types/@sha1n/about-time)\n![npm](https://img.shields.io/npm/v/@sha1n/about-time)\n\n\n# About-Time\n\nA collection of essential time related utilities.\n\n- [About-Time](#about-time)\n- [Install](#install)\n- [Utilities \u0026 Features](#utilities--features)\n  - [delay](#delay)\n  - [delayed](#delayed)\n  - [timeoutAround](#timeoutaround)\n  - [timeBounded](#timebounded)\n  - [sleep](#sleep)\n  - [stopwatch](#stopwatch)\n  - [until / eventually](#until--eventually)\n  - [Retry](#retry)\n    - [RetryPolicy](#retrypolicy)\n      - [Simple retry policy](#simple-retry-policy)\n      - [Fixed retry policy](#fixed-retry-policy)\n      - [Exponential backoff retry policy](#exponential-backoff-retry-policy)\n    - [retryAround](#retryaround)\n    - [retriable](#retriable)\n\n\n# Install\n```bash\nnpm i @sha1n/about-time\n```\n\n# Utilities \u0026 Features\n## delay\n```ts\n// Executes a function with delay and returns it's value\nawait delay(action, { time: 10 });\nawait delay(action, { time: 10, units: TimeUnit.Milliseconds });\nawait delay(action, { time: 10, units: TimeUnit.Milliseconds, unref: true });\n```\n\n## delayed\n```ts\n// Returns a new function that executes the specified action with delay and returns it's value\nconst delayedAction = delayed(action, { time: 10, units: TimeUnit.Milliseconds, unref: true });\nconst result = await delayedAction();\n```\n\n## timeoutAround\n```ts\n// Executes a function and guards it with a specified timeout\nawait timeoutAround(action, { time: 10 });\nawait timeoutAround(action, { time: 10, units: TimeUnit.Milliseconds });\nawait timeoutAround(action, { time: 10, units: TimeUnit.Milliseconds, unref: true });\n```\n\n## timeBounded\nWraps a given function with `timeoutAround` with the specified arguments.\n```ts\nconst timeBoundAction = timeBounded(action, options);\nconst result = await timeBoundAction();\n```\n\n\n## sleep\n```ts\n// Pauses execution for a specified amount of time\nawait sleep(10);\nawait sleep(10, { units: TimeUnit.Seconds });\nawait sleep(10, { units: TimeUnit.Seconds, unref: true });\n```\n\n## stopwatch\n```ts\n// Measure time between actions\nconst elapsed = stopwatch();\n    \n// do stuff here...\n\nconst elapsed1 = elapsed(TimeUnit.Milliseconds);\n\n// do more stuff here...\n\nconst elapsed2 = elapsed(TimeUnit.Seconds);\n```\n\n## until / eventually\n```ts\n// Waits for a condition to become true\nawait until(condition, { deadline: 10000 });\nawait until(condition, { deadline: 10000, interval: 100 });\nawait until(condition, { deadline: 10000, interval: 100, units: TimeUnit.Milliseconds });\nawait until(condition, { deadline: 10000, interval: 100, units: TimeUnit.Milliseconds, unref: true });\n```\n\n## Retry\n\n### RetryPolicy\n#### Simple retry policy\n```ts\n// 3 retries with 10 seconds wait between each\nconst retryPolicy = simpleRetryPolicy(3, 10, TimeUnit.Seconds);\n```\n\n#### Fixed retry policy\n```ts\n// 4 retries after 3, then after 10, 50 and 100 milliseconds\nconst retryPolicy = fixedRetryPolicy([3, 10, 50, 100], TimeUnit.Milliseconds);\n```\n\n#### Exponential backoff retry policy\nExponential backoff formula based retry policy with optional custom exponent base and a limit. \nThe optional `limit` provides control over maximum pause intervals, so they don't soar beyond reasonable values.\n\n**The formula used by this implementation is the following:** \n\ninterval\u003csub\u003ei\u003c/sub\u003e = min(limit, (exponential\u003csup\u003ei\u003c/sup\u003e - 1) / 2)\n\n```ts\nconst retryPolicy = exponentialBackoffRetryPolicy(/* count = */10, /* opts?: { exponential?: number, limit?: number, units?: TimeUnit }*/);\n```\n\n### retryAround\nExecutes the given function with retries based on the specified policy and *optional* predicate.\nThe predicate provides control over which errors we want to retry on.\n```ts\nconst result = await retryAround(action, retryPolicy, predicate);\n```\n\n### retriable\nWraps a given function with `retryAround` with the specified arguments.\n```ts\nconst retriableAction = retriable(action, retryPolicy, predicate);\nconst result = await retriableAction();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsha1n%2Fabout-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsha1n%2Fabout-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsha1n%2Fabout-time/lists"}