{"id":18410611,"url":"https://github.com/awaitbox/sleep","last_synced_at":"2025-07-17T01:36:46.280Z","repository":{"id":143735064,"uuid":"116435882","full_name":"awaitbox/sleep","owner":"awaitbox","description":"Await for a certain amount of time.","archived":false,"fork":false,"pushed_at":"2018-01-07T05:21:48.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-15T13:04:27.247Z","etag":null,"topics":["async","async-await","async-functions","await","promise","promise-library","sleep","sleep-timer"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/awaitbox.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":"2018-01-05T23:06:26.000Z","updated_at":"2018-01-05T23:38:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"38ef0e7f-151b-4c28-9872-43b3b0e753ef","html_url":"https://github.com/awaitbox/sleep","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/awaitbox/sleep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaitbox%2Fsleep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaitbox%2Fsleep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaitbox%2Fsleep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaitbox%2Fsleep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awaitbox","download_url":"https://codeload.github.com/awaitbox/sleep/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaitbox%2Fsleep/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265558783,"owners_count":23787979,"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-await","async-functions","await","promise","promise-library","sleep","sleep-timer"],"created_at":"2024-11-06T03:33:01.905Z","updated_at":"2025-07-17T01:36:46.241Z","avatar_url":"https://github.com/awaitbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n@awaitbox/sleep\n========================\n\nAwait for a certain amount of time.\n\n#### `npm i @awaitbox/sleep --save`\n\nThe `sleep` async function returns a promise that will resolve after the\nspecified amount of time. This is a convenient alternative for `setTimeout`.\nThis is inspired from `sleep(...)` in the C language, except that time is\nspecified in milliseconds rather than seconds.\n\nYou can use it in async functions:\n\n```js\nimport sleep from '@awaitbox/sleep'\n\nasync function main() {\n  await sleep( 1000 )\n  console.log( 'I fell asleep for a second!' )\n}\n\nmain()\n```\n\nYou can of course use it as a Promise:\n\n```js\nimport sleep from '@awaitbox/sleep'\n\nsleep( 1000 )\n  .then( data =\u003e console.log( 'I took a 1-second nap!' ) )\n```\n\nChain values will pass through if you use it in a Promise chain like follows:\n\n```js\nimport sleep from '@awaitbox/sleep'\n\nfetch( ... )\n  .then( ... )\n  .then( sleep.bind( null, 1000 ) ) // passes data through after 1 second\n  .then( data =\u003e console.log( 'use data for the awesome!', data ) )\n```\n\nNote\n----\n\nThis is written in ES2016+ JavaScript. To use this in pre-ES2016 environments,\nyou'll need to run this through a transpiler like [Babel](http://babeljs.io)\n(and I recommend using the\n[fast-async](https://github.com/MatAtBread/fast-async) plugin to get the best\nresults). See some tips here on wiring it up with\n[Webpack](https://webpack.js.org): http://2ality.com/2017/06/pkg-esnext.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaitbox%2Fsleep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawaitbox%2Fsleep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaitbox%2Fsleep/lists"}