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
v2.1.0
Size
3.6 KB gzip
Dependencies
Zero dependencies
BrowserNode ≥22SSRDeno
chunkgroupByretrydebounceclamp View all 10 exports

Why Arsenal?

Arsenal keeps common utilities at package root and places specialized behavior behind category entry points. This keeps autocomplete focused while preserving one dependency and tree-shakeable modules.

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 size3.6 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 { chunk, groupBy, retry } from '@vielzeug/arsenal';
import { cache } from '@vielzeug/arsenal/cache';
import { taskPool } from '@vielzeug/arsenal/async';

const pages = chunk([1, 2, 3, 4, 5], 2);
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(pages, byRole, health, profile);

Features

  • chunk: common array/string chunking from package root
  • 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
  • clamp: numeric bounds from package root
  • isEqual: structural equality from package root

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.