#tokio #tokio-util #browser #timer #delay-queue #utilities

wasmtimer

Time utils from std::time, tokio::time and tokio_util::time on WASM targets

7 releases (4 breaking)

0.4.1 Nov 17, 2024
0.4.0 Oct 17, 2024
0.3.0 Oct 11, 2024
0.2.1 Oct 11, 2024
0.0.1 Feb 15, 2023

#28 in WebAssembly

Download history 5578/week @ 2024-08-17 5661/week @ 2024-08-24 5927/week @ 2024-08-31 6383/week @ 2024-09-07 6078/week @ 2024-09-14 5732/week @ 2024-09-21 5263/week @ 2024-09-28 5515/week @ 2024-10-05 7377/week @ 2024-10-12 14073/week @ 2024-10-19 12427/week @ 2024-10-26 14461/week @ 2024-11-02 13858/week @ 2024-11-09 15932/week @ 2024-11-16 18791/week @ 2024-11-23 19272/week @ 2024-11-30

70,854 downloads per month
Used in 190 crates (27 directly)

MIT license

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

  • wasmtimer is only running on WASM browser targets and not using any tokio feature 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 (serde feature flag)
  • Worker and NodeJS Support
  • Test Utilities

Dependencies

~0.9–6MB
~36K SLoC