Writing
I write short notes on tools and habits that help with day-to-day engineering.
2026
- Match literal text with RegExp.escapeUse RegExp.escape when inserting literal search text into a larger regular expression that checks a filename suffix.
- Compress data with zstd in node:zlibCompare gzip and Zstandard on one JSON fixture, verify the decoded bytes, and stream an export with node:zlib.
- Send analytics late with fetchLaterQueue a small analytics snapshot while the page is active, replace it on each click, and fall back to a beacon.
- Pack samples with Float16Array and Math.f16roundHalve a Float32Array backing buffer with Float16Array and check rounding, underflow, and overflow before converting your data.
- Lazy pipelines with Iterator helpersUse iterator helpers to collect the first two matching records from a generator without reading its remaining values or building intermediate arrays.
- Format durations with Intl.DurationFormatFormat elapsed time in the user’s locale by splitting a minute count into units and choosing a label or timer style.
- Clone one commit with git clone --revisionCheck out a pinned Git commit with clone --revision, and add --depth=1 when your build needs the tree without its ancestors.
- Auto-cleanup with using and Symbol.disposeUse using and Symbol.dispose to close a handle before releasing its lock, even when your function returns early or throws.
- erasableSyntaxOnly for Node type strippingTurn on erasableSyntaxOnly to catch enums and other TypeScript syntax that Node cannot run by stripping types.
- Type require(esm) from CommonJS in TypeScriptSelect a TypeScript module mode for synchronous require of ES modules, and check when your Node runtime needs dynamic import.
- Review an agent's diff in five checksTrace an agent patch from changed files to a failing regression test and verify the revision you intend to merge.
- Define Tailwind v4 tokens with @themeMove a custom color and display font from Tailwind’s JavaScript config into CSS and keep using the same utility classes.
- Keep focus rings in a Tailwind upgradeRun the Tailwind v4 upgrade tool and check that renamed utilities preserve the focus treatment from your v3 project.
- Use built-in container queries in Tailwind v4Use named Tailwind container variants to change an event card’s layout and spacing by the width of its slot.
- Run one Vitest test by file lineTarget a single Vitest case from its editor location by passing the full test file path and declaration line.
- Compare local and field INP in DevToolsCompare local INP with Chrome field data and check the page and device scope before reproducing a slow interaction.
- Catch sync and async errors with Promise.tryWrap callbacks that may throw or return a promise and handle both failures with one catch handler.
- Handle pnpm 10 blocked postinstall scriptsReview a skipped dependency build, allow that package with onlyBuiltDependencies and rebuild it under pnpm 10.
- Restrict file access with --permissionAllow a Node script to read its reports directory and see how a read outside that directory fails.
- Pass ref as a prop in ReactRemove forwardRef from a React 19 input wrapper while keeping the DOM node that existing callers expect.