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

@node-3d/uv-loop

v0.1.0

Published

libuv loop scheduling primitives for Node3D

Readme

libuv loop scheduling for Node3D

This is a part of the Node3D project.

NPM Build Binaries

npm install @node-3d/uv-loop

@node-3d/uv-loop is a deliberately small native addon that exposes a hot libuv idle loop primitive. It starts one shared unref'd idle pump when imported, then lets TypeScript register one-shot and looping callbacks on top of that single native pump.

It is intended for render loops and other latency-sensitive work where recursive setImmediate or timer scheduling can produce visibly uneven frame pacing. It does not implement throttling; callers that need slower updates can throttle downstream through vsync, timers, or their own timing conditionals. It does not know about GLFW, WebGL, Three.js, or Node3D frame policies.

Quick Start

The API mirrors Node's timer handle style:

import { clearIdleLoop, setIdleLoop } from '@node-3d/uv-loop';

const loop = setIdleLoop(() => {
	render();

	if (done) {
		clearIdleLoop(loop);
	}
});

loop.unref();

For a one-shot idle callback:

import { setIdle } from '@node-3d/uv-loop';

setIdle(() => {
	updateOnce();
});

Handles are ref'd by default, like Node.js timer handles. Use unref() when idle work should not keep the process alive, and ref() to opt back in.

import { clearIdleLoop, setIdleLoop } from '@node-3d/uv-loop';

const loop = setIdleLoop(() => {
	render();

	if (done) {
		clearIdleLoop(loop);
	}
});

loop.unref();
loop.ref();
loop.hasRef();

API

  • setIdle(callback) - schedules a callback on the next libuv idle turn and returns an idle handle.
  • clearIdle(handle) - clears a one-shot or loop idle handle.
  • setIdleLoop(callback) - calls a callback on every libuv idle turn until cleared, and returns an idle handle.
  • clearIdleLoop(handle) - alias for clearIdle.

Idle handles expose Node timer-style lifecycle methods:

  • handle.ref() - keeps the process alive while this handle is active.
  • handle.unref() - allows the process to exit while this handle is active.
  • handle.hasRef() - returns whether this handle currently keeps the process alive.

The native addon still uses one shared libuv idle pump internally. Per-handle ref state is tracked in TypeScript and translated to the shared native pump.

Stub Mode

Set NODE_3D_UV_LOOP_STUB=1 or pass --node-3d-uv-loop-stub as an application argument to load a JavaScript stub instead of the native binary. The stub uses recursive setImmediate scheduling and implements the same public API. This is useful for CI, unsupported runtime experiments, or comparing behavior without the native libuv path.

Examples

Run the benchmark from this package:

node examples/benchmark.ts
node examples/benchmark.ts --seconds=10

Binary Origin

Release archives are built by this repository's public GitHub Actions workflows.

Attestations: https://github.com/node-3d/uv-loop/attestations

To verify a downloaded archive:

gh release download <tag> -R node-3d/uv-loop -p <platform>.gz
gh attestation verify <platform>.gz -R node-3d/uv-loop

Prebuilt addon binaries are provided for Windows x64/ARM64, Linux x64/ARM64, and macOS x64/ARM64. Because this addon calls libuv directly, release binaries are split by Node.js major version. Install chooses the binary tag from the runtime Node.js version:

  • Node.js 20 -> <package-version>-20
  • Node.js 22 -> <package-version>-22
  • Node.js 24 -> <package-version>-24
  • Node.js 26 -> <package-version>-26
  • Odd majors inside the supported range use the previous even major.
  • Older majors use the minimum supported binary major.
  • Newer majors use the maximum supported binary major.

There is no compilation step during the npm install command when a matching prebuilt archive is available.

ABI Notice

This package uses napi_get_uv_event_loop() and direct libuv APIs from <uv.h>. Node-API itself is ABI-stable, but Node.js does not guarantee libuv ABI stability across Node.js major versions. This package intentionally contains that risk in one small optional scheduling layer.

When the runtime Node.js major does not have an exact binary line, install logs a warning and falls back to the nearest configured binary line described above.