msleep

Small function that mimics the `usleep` C function, blocking the main thread.

Usage no npm install needed!

<script type="module">
  import msleep from 'https://cdn.skypack.dev/msleep';
</script>

README

msleep

Small function that mimics the usleep C function, blocking the main thread. But instead of microseconds works with miliseconds, to feel more JS-like.

Useful for:

  • Debugging race conditions
  • Simulate blocked UI thread on the browser

Installation

npm install --save msleep

Usage

msleep(5000) // Will block the main thread for half a second

caiogondim.com  ·  GitHub @caiogondim  ·  Twitter @caio_gondim