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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zakkster/lite-ticker

v1.0.1

Published

Zero-dependency RAF scheduler with game-pausable timers, fixed-timestep physics, and tab-switch guard.

Readme

@zakkster/lite-ticker

npm version npm bundle size npm downloads npm total downloads TypeScript Zero Dependencies License: MIT

A zero-dependency RAF scheduler with game-pausable timers and optional fixed-timestep physics.

One requestAnimationFrame loop to rule them all — per-frame tasks, timeouts, and intervals that pause when the game pauses and don't explode after a tab switch.

Features

  • Variable or fixed-timestep loops — choose per game
  • Game-pausable setTimeout / setInterval — tied to RAF, not wall clock
  • Tab-switch guard — caps dt to prevent physics explosions after background
  • Disposer pattern — every add/setTimeout/setInterval returns a cleanup function
  • Snapshot-safe timer iteration — callbacks can safely add/remove timers mid-frame
  • Zero dependencies, < 1 KB

Installation

npm install @zakkster/lite-ticker

Quick Start

import { Ticker } from '@zakkster/lite-ticker';

const ticker = new Ticker();

// Add a per-frame task (receives dt in ms)
const removeUpdate = ticker.add((dt) => {
    player.x += player.vx * (dt / 1000);
});

// Game-pausable timeout (freezes when ticker is paused)
const cancelCountdown = ticker.setTimeout(() => {
    console.log('3 seconds of GAME TIME have passed');
}, 3000);

ticker.start();

// Later: pause (all tasks and timers freeze)
ticker.pause();

// Resume (no delta spike — timestamp resets)
ticker.start();

// Clean up
removeUpdate();
cancelCountdown();
ticker.destroy();

Options

const ticker = new Ticker({
    fixedStep: 16.66, // Fixed timestep in ms (0 = variable dt, default)
    maxDt: 100,       // Tab-switch dt cap in ms (default: 100)
});

API

Lifecycle

| Method | Description | |--------|-------------| | .start() | Start the loop. Resets timestamp. Idempotent. | | .pause() | Pause. Tasks and timers freeze. | | .destroy() | Stop and clear everything. Idempotent. |

Per-Frame Tasks

const remove = ticker.add((dt) => {
    // dt is in ms — either variable or fixedStep
    physics.update(dt);
    renderer.draw();
});

remove(); // stop receiving frames

Timers

// One-shot (like setTimeout but game-pausable)
const cancel = ticker.setTimeout(() => {
    showModal('Game Over');
}, 5000);

// Repeating (like setInterval but game-pausable)
const stop = ticker.setInterval(() => {
    spawnEnemy();
}, 2000);

cancel(); // cancel before it fires
stop();   // stop the interval

Fixed Timestep

For deterministic physics, use fixedStep:

const ticker = new Ticker({ fixedStep: 16.66 }); // 60 updates/sec

ticker.add((dt) => {
    // dt is always 16.66, regardless of frame rate.
    // If a frame takes 33ms, this runs twice.
    // If a frame takes 8ms, this doesn't run (accumulator < step).
    body.velocity.y += GRAVITY * dt;
    body.position.y += body.velocity.y * dt;
});

The accumulator pattern prevents the "spiral of death" — if the game can't keep up, the dt cap kicks in and frames are skipped rather than endlessly catching up.

Tab-Switch Guard

When a user switches tabs and comes back 5 seconds later, the raw dt would be 5000ms. Without a guard, physics objects teleport across the screen and timers fire all at once.

lite-ticker caps dt at maxDt (default: 100ms). After the cap, dt falls back to fixedStep (or 16.66ms if variable), producing one normal-looking frame instead of a physics explosion.

Timer Safety

Timer callbacks can safely add or remove other timers during execution — the timer set is snapshotted before iteration. Intervals carry over their remainder for drift-free scheduling (elapsed %= delay).

TypeScript

import { Ticker, type TickerOptions, type Disposer } from '@zakkster/lite-ticker';

const ticker = new Ticker({ fixedStep: 16.66 });

const remove: Disposer = ticker.add((dt: number) => {
    // fully typed
});

License

MIT