Skip to content
arsenal logoArsenalUtilities
Tree-shakeable TypeScript utilities with focused category entry points for arrays, async work, caching, objects, strings, math, and guards.
Version
v3.0.0
Size
4.0 KB gzip
Dependencies
Zero dependencies
BrowserNode ≥22SSRDeno
groupByretrydebounceisEqualtaskPool View all 10 exports

Why Arsenal?

Arsenal provides typed, zero-dependency utilities that reduce repeated application code: collection transforms, numeric operations, retry and cancellation, caching, safe-path traversal, and deterministic serialization. The root stays curated while category entry points expose the broader toolkit. Exact platform aliases remain excluded.

ts
// Before
const users = JSON.parse(raw).filter((user) => user.name.includes(query));

// After
import { fuzzyFilter } from '@vielzeug/arsenal/array';
import { tryParseJson } from '@vielzeug/arsenal/object';

const parsed = tryParseJson(raw);
const users = parsed.ok ? fuzzyFilter(parsed.value as User[], query, { select: (user) => user.name }) : [];
FeatureArsenallodash-esRemeda
Bundle size4.0 KB~72 kB~18 kB
Typed root utilitiesPartial
Category entry pointsPartialPartial
Async task pool and cache
Zero dependencies

Use Arsenal when you need one typed utility dependency with focused subpaths for specialized behavior.

Consider narrower alternatives when you need only platform APIs or a small functional subset.

Installation

sh
pnpm add @vielzeug/arsenal
sh
npm install @vielzeug/arsenal
sh
yarn add @vielzeug/arsenal

Quick Start

ts
import { groupBy, retry } from '@vielzeug/arsenal';
import { cache } from '@vielzeug/arsenal/cache';
import { taskPool } from '@vielzeug/arsenal/async';

const byRole = groupBy([{ role: 'admin' }, { role: 'user' }], (user) => user.role);

const pool = taskPool({ concurrency: 2 });
const health = await pool.run((signal) => retry(() => fetch('/health', { signal }).then((response) => response.json())));

const responses = cache<string, unknown>({ ttlMs: 60_000 });
const profile = await responses.getOrLoad('/profile', () => fetch('/profile').then((response) => response.json()));

pool.dispose();
console.log(byRole, health, profile);

Features

  • retry: retry async work with cancellation support from package root
  • taskPool: bounded, disposable concurrent work from /async
  • cache: identity-keyed TTL cache with async load deduplication from /cache
  • fuzzyFilter: explicit-field fuzzy filtering from /array
  • tryParseJson: preserve JSON syntax failures from /object
  • allocate: lossless proportional distribution from /math
  • chunk, zip, compact: typed collection transforms from /array
  • range, average, median: common numeric operations from /math
  • assert, tap: typed control-flow helpers from /function
  • isEqual: structural equality from package root
  • hash: deterministic serialization for stable cache keys from /object

Documentation

See Also

  • Spell — validate unknown JSON data after tryParseJson.
  • Vault — persistent storage; Arsenal cache is in-memory only.
  • Tempo — date/time utilities kept outside Arsenal.
  • Coins — money formatting and currency conversion.