{"_id":"atomic-sleep","_rev":"475848","name":"atomic-sleep","description":"Zero CPU overhead, zero dependency, true event-loop blocking sleep","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"davidmarkclements","email":"huperekchuno@googlemail.com"}],"time":{"modified":"2021-08-05T08:38:15.000Z","created":"2020-03-09T18:56:01.508Z","1.0.0":"2020-03-09T18:56:01.508Z"},"users":{},"author":{"name":"David Mark Clements","url":"@davidmarkclem"},"repository":{"type":"git","url":"git+https://github.com/davidmarkclements/atomic-sleep.git"},"versions":{"1.0.0":{"name":"atomic-sleep","version":"1.0.0","description":"Zero CPU overhead, zero dependency, true event-loop blocking sleep","main":"index.js","scripts":{"test":"tap -R classic- -j1 test","lint":"standard","ci":"npm run lint && npm test"},"keywords":["sleep","pause","wait","performance","atomics"],"engines":{"node":">=8.0.0"},"author":{"name":"David Mark Clements","url":"@davidmarkclem"},"license":"MIT","devDependencies":{"standard":"^14.3.1","tap":"^14.10.6","tape":"^4.13.2"},"dependencies":{},"repository":{"type":"git","url":"git+https://github.com/davidmarkclements/atomic-sleep.git"},"bugs":{"url":"https://github.com/davidmarkclements/atomic-sleep/issues"},"homepage":"https://github.com/davidmarkclements/atomic-sleep#readme","gitHead":"b8149d3ca276c84a54fa8fa1478f9cc79aabc15a","_id":"atomic-sleep@1.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"shasum":"eb85b77a601fc932cfe432c5acd364a9e2c9075b","size":2822,"noattachment":false,"key":"/atomic-sleep/-/atomic-sleep-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/atomic-sleep/download/atomic-sleep-1.0.0.tgz"},"maintainers":[{"name":"davidmarkclements","email":"huperekchuno@googlemail.com"}],"_npmUser":{"name":"davidmarkclements","email":"huperekchuno@googlemail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/atomic-sleep_1.0.0_1583780161396_0.3874882191086746"},"_hasShrinkwrap":false,"publish_time":1583780161508,"_cnpm_publish_time":1583780161508}},"readme":"<h1 align=\"center\">Welcome to atomic-sleep ⏱️</h1>\n<p>\n  <img alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000\" />\n  <a href=\"#\" target=\"_blank\">\n    <img alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" />\n  </a>\n  <a href=\"https://twitter.com/davidmarkclem\" target=\"_blank\">\n    <img alt=\"Twitter: davidmarkclem\" src=\"https://img.shields.io/twitter/follow/davidmarkclem.svg?style=social\" />\n  </a>\n</p>\n\n> Zero CPU overhead, zero dependency, true event-loop blocking sleep\n\n## Usage\n\n```js\nconst sleep = require('atomic-sleep')\n\nconsole.time('sleep')\nsetTimeout(() => { console.timeEnd('sleep') }, 100) \nsleep(1000)\n```\n\nThe `console.time` will report a time of just over 1000ms despite the `setTimeout`\nbeing 100ms. This is because the event loop is paused for 1000ms and the setTimeout\nfires immediately after the event loop is no longer blocked (as more than 100ms have passed).\n\n## Install\n\n```sh\nnpm install\n```\n\n## Run tests\n\n```sh\nnpm test\n```\n\n## Support\n\nNode and Browser versions that support both `SharedArrayBuffer` and `Atomics` will have (virtually) zero CPU overhead sleep. \n\nFor Node, Atomic Sleep can provide zero CPU overhead sleep from Node 8 and up.\n\nFor browser support see https://caniuse.com/#feat=sharedarraybuffer and https://caniuse.com/#feat=mdn-javascript_builtins_atomics.\n\n\nFor older Node versions and olders browsers we fall back to blocking the event loop in a way that will cause a CPU spike. \n\n\n\n## Author\n\n???? **David Mark Clements (@davidmarkclem)**\n\n* Twitter: [@davidmarkclem](https://twitter.com/davidmarkclem)\n* Github: [@davidmarkclements](https://github.com/davidmarkclements)\n","_attachments":{},"homepage":"https://github.com/davidmarkclements/atomic-sleep#readme","bugs":{"url":"https://github.com/davidmarkclements/atomic-sleep/issues"},"license":"MIT"}