9 unstable releases
| 0.4.3 | Sep 1, 2025 |
|---|---|
| 0.4.2 | Jun 17, 2025 |
| 0.4.1 | Nov 17, 2024 |
| 0.2.0 | Mar 11, 2023 |
#20 in WebAssembly
290,624 downloads per month
Used in 426 crates
(39 directly)
115KB
2.5K
SLoC
wasmtimer-rs
An implementation of time based functionalities from std::time, tokio::time,
tokio_util::time for WASM targets. This crate tries to closely
replicate above APIs. Users only have to change their use scripts by
using a cfg macro.
#[cfg(not(target_family="wasm"))]
use tokio::time::*;
#[cfg(target_family="wasm")]
use wasmtimer::tokio::*;
Check the API Documentation for more details.
Story
Core idea and core modules in src/timer folder were copied from
this crate. This crate is
abandoned now due to lack of maintainability. I've hard forked it,
added some additional features and released to use for
this PR.
tokio::time vs wasmtimer
wasmtimeris only running on WASM browser targets and not using anytokiofeature as a dependency.- This timer crate not supporting
Auto-advance
like in the tokio crate. Because we can not track the background
tasks(
Promise) in browser scope. If we implemented such without caring about background tasks, then this implementation will not match with the tokio's original implementation.
Features
- Serde Support (
serdefeature flag) - Worker and NodeJS Support
- Test Utilities
Dependencies
~0.7–1.7MB
~31K SLoC