@ewanc26/utils
ewan
March 6, 2026
@ewanc26/utils is a zero-dependency TypeScript utility library extracted from ewancroft.uk. It provides helpers for date and number formatting, URL manipulation, input validation, locale detection, and RSS feed generation.
Part of the @ewanc26/pkgs monorepo.
Installation
Modules
Date & Locale
formatRelativeTime returns relative strings (Xm ago, Xh ago, Xd ago) for recent dates, falling back to a localised short date beyond 7 days.
Number Formatting
Both functions accept an optional locale string; otherwise they use navigator.language with an en-GB fallback.
URL Utilities
Validators & Text Helpers
RSS Generation
createRSSResponse returns a Response with Content-Type: application/rss+xml; charset=utf-8 and a configurable Cache-Control header (default: 1 hour).
Lower-level helpers — escapeXml, escapeXmlAttribute, normalizeCharacters, formatRSSDate, generateRSSItem — are also exported if you need to build feeds manually.
SSR Compatibility
All functions are SSR-safe. Functions that need navigator.language or window check for their availability and fall back to en-GB / sensible defaults on the server.
Tech Stack
TypeScript 5.9+. No runtime dependencies. Compiled to ESM with tsc.
Licence
AGPL-3.0-only — see the pkgs monorepo.
Discussion in the ATmosphere