{"id":21152871,"url":"https://github.com/pilaton/sleep-sleep","last_synced_at":"2025-08-20T07:13:26.019Z","repository":{"id":208680968,"uuid":"722235512","full_name":"Pilaton/sleep-sleep","owner":"Pilaton","description":"A tiny and simple JavaScript code execution delay library.","archived":false,"fork":false,"pushed_at":"2024-12-05T18:48:47.000Z","size":144,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T18:52:46.001Z","etag":null,"topics":["delay","javascript","playwright","puppeteer","sleep","sleep-timer","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/sleep-sleep","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/Pilaton.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,"zenodo":null}},"created_at":"2023-11-22T18:16:00.000Z","updated_at":"2024-12-05T18:48:18.000Z","dependencies_parsed_at":"2023-12-14T10:51:33.472Z","dependency_job_id":"d4c1f4ab-2f05-4dfe-a757-a25ddd2b64cb","html_url":"https://github.com/Pilaton/sleep-sleep","commit_stats":null,"previous_names":["pilaton/sleep-sleep"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/Pilaton/sleep-sleep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fsleep-sleep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fsleep-sleep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fsleep-sleep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fsleep-sleep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pilaton","download_url":"https://codeload.github.com/Pilaton/sleep-sleep/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fsleep-sleep/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271281006,"owners_count":24732111,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","javascript","playwright","puppeteer","sleep","sleep-timer","typescript"],"created_at":"2024-11-20T10:47:11.053Z","updated_at":"2025-08-20T07:13:25.993Z","avatar_url":"https://github.com/Pilaton.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sleep-sleep ⏰ \u003c!-- omit in toc --\u003e\n\nA tiny and simple JavaScript code execution delay library.  \n**0.35 kB!** 🚀 and **No dependencies** 🎉\n\nUnder the hood, setTimeout is used, so it's simple and reliable.\n\n## Table of contents \u003c!-- omit in toc --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n\n## Install\n\nStep 1:\n\n```bash\nnpm install sleep-sleep\n```\n\nStep 2:\n\n```js\nimport sleep from 'sleep-sleep';\n```\n\nOr if you want to use CommonJS:\n\n```js\nconst sleep = require('sleep-sleep');\n```\n\n## Usage\n\nAn example of using the sleep function:\n\n```js\nimport sleep from 'sleep-sleep';\n\nasync function demoFunction() {\n  console.log('3-second delay...');\n  await sleep(3000); // 3000 ms delay (3 seconds)\n  console.log('Delay completed.');\n}\n\ndemoFunction();\n```\n\nYou can also use a random delay between the minimum and maximum time value:\n\n```js\nimport sleep from 'sleep-sleep';\n\nasync function demoFunction() {\n  console.log('Random delay...');\n  await sleep(1000, 5000); // Random delay between 1 and 5 seconds\n  console.log('Delay completed after e.g. 3.47 seconds.');\n}\n\ndemoFunction();\n```\n\nRandom delay is very useful for example in [Puppeteer](https://pptr.dev/) and [Playwright](https://playwright.dev/) related projects, where a random pause between actions gives your automation a more human-like 👨‍🌾 appearance.\n\n## API\n\n```js\nsleep(minMs: number, maxMs?: number): Promise\u003cvoid\u003e\n```\n\n`minMs`: Minimum number of milliseconds for delay.\n\n`maxMs` (optional): The maximum number of milliseconds for the delay. If not specified, the delay will be fixed and equal to `minMs`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilaton%2Fsleep-sleep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpilaton%2Fsleep-sleep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilaton%2Fsleep-sleep/lists"}