#sleep #window #js #web-worker #windowless #rely

windowless_sleep

A sleep function for wasm that doesn't rely on window

1 unstable release

0.1.1 Oct 16, 2023

#997 in WebAssembly

MIT license

3KB

windowless sleep

The web-sys crate uses the window object to access the global setTimeout function, which doesn't work in contexts like web workers, WASI, node.js, or, most importantly, bun.

This is a version of sleep that just uses whatever global setTimeout function happens to exist. No idea if this will help with WASI but it works in web workers and bun.

Dependencies

~1–2.8MB
~52K SLoC