{"id":13511915,"url":"https://github.com/erikdubbelboer/node-sleep","last_synced_at":"2025-05-15T19:09:27.270Z","repository":{"id":2638118,"uuid":"3627029","full_name":"erikdubbelboer/node-sleep","owner":"erikdubbelboer","description":"Add sleep() and usleep() to nodejs","archived":false,"fork":false,"pushed_at":"2022-12-30T17:50:12.000Z","size":101,"stargazers_count":453,"open_issues_count":4,"forks_count":40,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-18T04:02:25.500Z","etag":null,"topics":["nodejs"],"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/erikdubbelboer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-05T13:01:09.000Z","updated_at":"2024-04-09T18:24:46.000Z","dependencies_parsed_at":"2023-01-13T11:59:35.688Z","dependency_job_id":null,"html_url":"https://github.com/erikdubbelboer/node-sleep","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikdubbelboer%2Fnode-sleep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikdubbelboer%2Fnode-sleep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikdubbelboer%2Fnode-sleep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erikdubbelboer%2Fnode-sleep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erikdubbelboer","download_url":"https://codeload.github.com/erikdubbelboer/node-sleep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404357,"owners_count":22065641,"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":["nodejs"],"created_at":"2024-08-01T03:01:18.713Z","updated_at":"2025-05-15T19:09:27.245Z","avatar_url":"https://github.com/erikdubbelboer.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/erikdubbelboer/node-sleep.png?branch=master)](https://travis-ci.org/erikdubbelboer/node-sleep)\n[![Build status](https://ci.appveyor.com/api/projects/status/09kubqqykjaxdrab?svg=true)](https://ci.appveyor.com/project/erikdubbelboer/node-sleep)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep?ref=badge_shield)\n\nsleep\n=====\n\nAdd [`sleep()`][1], `msleep()` and [`usleep()`][2] to Node.js, via a C++ binding.\n\nThis is mainly useful for debugging.\n\nNote that because this is a C++ module, it will need to be built on the system you are going to use it on.\n\nThese calls will block execution of all JavaScript by halting Node.js' event loop!\n==================================================================================\n\nAlternative\n-----------\n\nWhen using nodejs `9.3` or higher it's better to use [Atomics.wait](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait) which doesn't require compiling this C++\nmodule.\nThe `sleep` and `msleep` functions can be implemented like this:\n```js\nfunction msleep(n) {\n  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);\n}\nfunction sleep(n) {\n  msleep(n*1000);\n}\n```\nIf you require `usleep` this module is still required.\n\nUsage\n-----\n\n    var sleep = require('sleep');\n\n* `sleep.sleep(n)`: sleep for `n` seconds\n* `sleep.msleep(n)`: sleep for `n` miliseconds\n* `sleep.usleep(n)`: sleep for `n` microseconds (1 second is 1000000 microseconds)\n\n\n[1]: http://linux.die.net/man/3/sleep\n[2]: http://linux.die.net/man/3/usleep\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Ferikdubbelboer%2Fnode-sleep?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikdubbelboer%2Fnode-sleep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikdubbelboer%2Fnode-sleep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikdubbelboer%2Fnode-sleep/lists"}