{"id":13728171,"url":"https://github.com/ai/nanodelay","last_synced_at":"2025-04-04T10:03:50.426Z","repository":{"id":46938573,"uuid":"107812168","full_name":"ai/nanodelay","owner":"ai","description":"A tiny (37 bytes) Promise wrapper around setTimeout","archived":false,"fork":false,"pushed_at":"2023-07-20T17:46:54.000Z","size":1279,"stargazers_count":196,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T09:01:54.800Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ai.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-21T20:07:33.000Z","updated_at":"2025-03-19T16:15:55.000Z","dependencies_parsed_at":"2024-06-18T14:15:17.371Z","dependency_job_id":null,"html_url":"https://github.com/ai/nanodelay","commit_stats":{"total_commits":143,"total_committers":6,"mean_commits":"23.833333333333332","dds":0.09090909090909094,"last_synced_commit":"fb1fa371b9f1249f6a6666e329697910aa918872"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanodelay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanodelay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanodelay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai%2Fnanodelay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ai","download_url":"https://codeload.github.com/ai/nanodelay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149503,"owners_count":20891954,"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":[],"created_at":"2024-08-03T02:00:38.116Z","updated_at":"2025-04-04T10:03:50.387Z","avatar_url":"https://github.com/ai.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Performance"],"readme":"# Nano Delay\n\nA tiny `Promise` wrapper around `setTimeout` for JavaScript.\nReturns a `Promise` and resolve it after a specific amount of time.\n\n* Only **45 bytes** (minified and gzipped),\n  10 times smaller than [`delay`] library.\n* Has good **ES modules** and **TypeScript** support.\n\n```js\nimport { delay } from 'nanodelay'\n\nasync function foo () {\n  await delay(300)\n  // Executed after 300 milliseconds\n}\n\ndelay(300).then(() =\u003e {\n  // Executed after 300 milliseconds\n})\n```\n\n[`delay`]: https://github.com/sindresorhus/delay\n\n\u003ca href=\"https://evilmartians.com/?utm_source=nanodelay\"\u003e\n  \u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\"\n       alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\n\u003c/a\u003e\n\n\n## Usage\n\nThe second argument will be used in `Promise` as resolved value\n(useful to pass variables between scopes):\n\n```js\ncreateClient().then(client =\u003e {\n  expect(client).toBeOK\n  return delay(50, client)\n}).then(client =\u003e {\n  expect(client).toBeConnected()\n})\n```\n\nFor quick hacks you can load Nano Delay from CDN. Do not use it in production because of low performance.\n\n```js\nimport { delay } from 'https://cdn.jsdelivr.net/npm/nanodelay/index.js'\n```\n\n\n## Future\n\nNode.js 16+ has built-in Promise-based `setTimeout`. After January 2023\nyou can remove `nanodelay` from your dependencies.\n\n```js\nimport { setTimeout } from 'timers/promises'\n\nawait setTimeout(5000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai%2Fnanodelay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fai%2Fnanodelay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai%2Fnanodelay/lists"}