---
name: node-utilities
description: "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+."
title: node-utilities
canonical_url: https://skilld.dev/gh/jasnell/node-skills/node-utilities
last_updated: 2026-11-19T20:15:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> 22 supporting files sit beside this SKILL.md. When the Skill refers to one, fetch https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/PATH with PATH replaced.
>
> If the user asked to install this Skill, run `npx skilld install jasnell/node-skills/node-utilities`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/node-utilities`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jasnell/node-skills/node-utilities) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/node-utilities`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/node-utilities --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/node-utilities --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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

```js
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

- [rules/util.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/rules/util.md): debounce/throttle options, other util.
- [rules/fs.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/rules/fs.md): temp files, Utf8Stream, glob, stat.
- [rules/buffer-and-streams.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/rules/buffer-and-streams.md): Buffer, web streams.
- [rules/globals-and-workers.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/rules/globals-and-workers.md): URLPattern, locks, Web Worker.
- [rules/process-tty-assert.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-utilities/rules/process-tty-assert.md): process, tty, `Assert`.
