Index of every page on this site: llms.txt
All skills
jasnell avatar

/node-utilities

@5f83e6c
Run it yourself

Small built-ins added since Node.js 24 that replace common npm packages. Use for debounce/throttle, temp files and directories with automatic cleanup, URL pattern matching or routing, an in-process mutex (Web Locks), Web Workers, partial deep-equality checks, UTF-8 byte length or fs.glob depth limits, or when about to install lodash.debounce, p-throttle, tmp or urlpattern-polyfill. Covers util.debounce/throttle, isPartialDeepStrictEqual, markPromiseAsHandled, Buffer.stringLength, fs.mkdtempDisposable, fs.mkstemp, openAsBlobSync, Utf8Stream, URLPattern, navigator.locks, the global Worker, addUncaughtExceptionCaptureCallback and tty raw modes. Node.js 24+.

Use this Skill: https://skilld.dev/gh/jasnell/node-skills/node-utilities

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈170 tokens for metadata: the name and description. ≈951 when used: this file. ≈6.1k more on demand in 6 files.

Description uses 8.5% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈679 characters, or 8.5%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Utilities since v24

Feature Versions Stability Flag
util.debounce, throttle, markPromiseAsHandled v26.10.0, v24.22.0 2
util.isPartialDeepStrictEqual, Buffer.stringLength, isLatin1 v26.11.0 2
util.convertProcessSignalToExitCode; streamConsumers.bytes v25.4.0; v25.6.0; both v24.14.0 2
styleText('#rrggbb'), glob({ followSymlinks }) v26.1.0, v24.16.0 2
fs.mkdtempDisposable[Sync] v24.4.0 2
fs.mkstemp[Sync] v27.0.0 1
fs.Utf8Stream v24.6.0 1
glob({ maxDepth }); fs.openAsBlobSync v26.9.0; v26.10.0 2
async stat({ throwIfNoEntry }) v25.7.0 (also v24.19.0) 2
stat/lstat signal; allocUnsafe(n, alignment) v26.8.0 2
Stats *Instant (Temporal) v26.2.0 2
blob.textStream(), ReadableStreamTee v26.5.0, v24.19.0 2, 1
URLPattern global v24.0.0 1
navigator.locks, worker_threads.locks v24.5.0 1
ErrorEvent; QuotaExceededError v25.0.0; v26.0.0 2
Global Web Worker v26.9.0, default-on in main 1 --experimental-web-worker
process.addUncaughtExceptionCaptureCallback v25.9.0 1
process.ref/unref Stable v26.11.0 (added v23.6.0, v22.14.0) 2
tty setRawMode('raw'|'io'), rawMode v26.8.0, v24.21.0 2
stream.compose Stable v26.2.0, v24.19.0 2
assert.Assert; skipPrototype v24.6.0, v22.19.0; v24.9.0 2

Experimental API. Before relying on these details, run the node-experimental-check skill's probe (or node --version plus a feature-detect one-liner) and check the docs for the installed version: https://nodejs.org/docs/<version>/api/<module>.html. If the installed version disagrees with this skill, the installed version wins.

Patterns

import { debounce, throttle } from 'node:util';
const save = debounce(async (doc) => write(doc), 300); // all callers get the last result
save.cancel(); // pending reject with AbortError
const get = throttle((id) => load(id), 2, 1000); // 2 starts/s; extras queue

await using dir = await fsp.mkdtempDisposable(join(tmpdir(), 'job-')); // rm -r at scope exit
const { path, handle } = await fsp.mkstemp(join(dir.path, 'f-')); // 27+, mode 0600
await using h = handle; // the result is not disposable

new URLPattern({ pathname: '/users/:id(\\d+)' }).exec(url)?.pathname.groups.id;
await navigator.locks.request('cache', () => refresh()); // resolves with refresh()'s value

Pitfalls

  • Older versions ignore new args silently: allocUnsafe(n, 3), glob({ maxDepth }); setRawMode('io') acts as raw.
  • mkdtempDisposable(Buffer) throws on main after creating the directory.
  • using on fs.Utf8Stream calls destroy() and drops buffered data. Call end().
  • Locks are per process. A queued request does not keep a worker alive.
  • new Worker('./w.js') resolves against cwd; pass a URL.

Don't

  • lodash.debounce/throttle, p-throttle → util.debounce/throttle.
  • tmp/tmp-promise → mkdtempDisposable/mkstemp; sonic-boom → Utf8Stream.
  • urlpattern-polyfill → URLPattern; in-process async-mutex → navigator.locks (not proper-lockfile: cross-process).
  • chalk.hex() → styleText('#hex'); 128 + signals[s] → convertProcessSignalToExitCode.

Reference

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    The skill provides comprehensive documentation and verified code examples for new Node.js v24+ features. No security risks were identified.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at 5f83e6c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated last week

README badge

README badge for jasnell/node-skills/node-utilities