{
"path": "/projects/utils",
"site": "at://did:plc:ofrbh253gwicbkc5nktqepol/site.standard.publication/3mfyq5mpohw25",
"tags": [
"pkgs",
"typescript"
],
"$type": "site.standard.document",
"title": "@ewanc26/utils",
"description": "Shared utility functions extracted from ewancroft.uk — date formatting, number formatting, URL helpers, validators, RSS generation, and locale detection.",
"publishedAt": "2026-03-06T00:00:00.000Z",
"textContent": "@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.\n\nPart of the @ewanc26/pkgs monorepo.\n\nInstallation\n\nModules\n\nDate & Locale\n\nformatRelativeTime returns relative strings (Xm ago, Xh ago, Xd ago) for recent dates, falling back to a localised short date beyond 7 days.\n\nNumber Formatting\n\nBoth functions accept an optional locale string; otherwise they use navigator.language with an en-GB fallback.\n\nURL Utilities\n\nValidators & Text Helpers\n\nRSS Generation\n\ncreateRSSResponse returns a Response with Content-Type: application/rss+xml; charset=utf-8 and a configurable Cache-Control header (default: 1 hour).\n\nLower-level helpers — escapeXml, escapeXmlAttribute, normalizeCharacters, formatRSSDate, generateRSSItem — are also exported if you need to build feeds manually.\n\nSSR Compatibility\n\nAll 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.\n\nTech Stack\n\nTypeScript 5.9+. No runtime dependencies. Compiled to ESM with tsc.\n\nLicence\n\nAGPL-3.0-only — see the pkgs monorepo.",
"canonicalUrl": "https://docs.ewancroft.uk/projects/utils"
}