npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thi.ng/wasm-api-schedule

v1.0.61

Published

Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps

Readme

@thi.ng/wasm-api-schedule

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 211 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps. This is a support package for @thi.ng/wasm-api.

The package provides a WASM bridge API and abstraction for scheduling function calls via:

  • once: setTimeout() / clearTimeout()
  • interval: setInterval() / clearInterval()
  • immediate: setImmediate() / clearImmediate()(1)
  • raf: requestAnimationFrame() / cancelAnimationFrame()(1)

(1) Fallback provided in case the JS host env has no native support

These different types of delayed execution are unified into the single schedule() function and the ScheduleType enum. Scheduled callbacks can be cancelled via cancel()...

Zig example:

const wasm = @import("wasm-api");
const schedule = @import("wasm-api-schedule");

// ...

// the WASM API modules auto-initialize themselves if the root source
// file exposes a `WASM_ALLOCATOR`, otherwise you'll have to initialize manually:
try schedule.init(customAllocator);

// user callback function
fn exampleCallback(raw: ?*anyopaque) callconv(.C) void {
    if (wasm.ptrCast(*u32, raw)) |state| {
        // do something ...
    }
}

// arbitrary user state
var state: u32 = 0xdecafbad;

// schedule a single/one-off callback 500ms in the future
const listenerID = try schedule.schedule(
    .once,
    500,
    exampleCallback,
    &state,
);

// ...or maybe cancel it again
schedule.cancel(listenerID);

IMPORTANT: In Zig v0.12+ all event handlers must explicitly specify callconv(.C) See docs for more reference.

Also see the zig-counter and zig-todo-list example projects for more advanced usage...

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/wasm-api-schedule

ESM import:

import * as was from "@thi.ng/wasm-api-schedule";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/wasm-api-schedule"></script>

JSDelivr documentation

Package sizes (brotli'd, pre-treeshake): ESM: 561 bytes

Dependencies

Note: @thi.ng/api is in most cases a type-only import (not used at runtime)

Usage examples

Three projects in this repo's /examples directory are using this package:

| Screenshot | Description | Live demo | Source | |:---------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------|:----------------------------------------------------|:---------------------------------------------------------------------------------| | | Simple Zig/WASM click counter DOM component | Demo | Source | | | Zig-based To-Do list, DOM creation, local storage task persistence | Demo | Source | | | Basic Zig/WebAssembly WebGL demo | Demo | Source |

API

Generated API docs

TODO

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-wasm-api-schedule,
  title = "@thi.ng/wasm-api-schedule",
  author = "Karsten Schmidt",
  note = "https://thi.ng/wasm-api-schedule",
  year = 2022
}

License

© 2022 - 2025 Karsten Schmidt // Apache License 2.0