Reinforcements
A TypeScript utility belt. ~130 functions for objects, strings, numbers, async, randomness, and functional composition. Path-first object access, smart string casings, real concurrency helpers, deterministic randomness — all from one import, all tree-shakable, all typed.
Highlighted features
~130 typed helpers
One install replaces a handful of lodash modules — and ships with TypeScript-first signatures, not adapter packages.
Path-first object access
get(user, “profile.email”) autocompletes every legal dot-notation path and infers the value type — no as casts, no manual generics.
Smart string casings
The casing family shares one words() tokenizer that handles acronyms correctly: AIAgent → [“AI”,“Agent”], not [“A”,“I”,“Agent”].
Async helpers that scale
retry with backoff, pMap with concurrency caps, timeout, defer, sleep — without pulling in the whole p-* ecosystem.
Random namespace
Random.int(1, 10), Random.uuid(), Random.sample(arr), Random.seed(n) for deterministic test fixtures. Namespace class, never new.
lazy breaks cycles
The one tool that resolves ES-module circular imports cleanly — defer evaluation until first read.
Install
npm install @mongez/reinforcementsyarn add @mongez/reinforcementspnpm add @mongez/reinforcementsQuick peek
import { get, slugify, debounce, retry, pMap, Random } from "@mongez/reinforcements";
const email = get(user, "profile.email"); // typed by pathconst slug = slugify("Café & Croissant"); // "cafe-croissant"const save = debounce(persist, 500, { maxWait: 3_000 }); // cancel / flush / pendingconst data = await retry(() => fetch(url), { attempts: 5 });const docs = await pMap(urls, fetch, { concurrency: 5 });const id = Random.uuid();A taste of the breadth — typed path access, casing, debouncing, retries, parallel mapping, and randomness all from one import.
Namespaces
| Namespace | Count | Examples |
|---|---|---|
object | 24 | get, set, pick, omit, compact, merge, clone, flatten, walk, diff |
string | ~45 | Casing family, slugify, truncate, template, mask, stripHtmlTags |
number | 12 | round, clamp, formatBytes, percentage, safeDivide |
array | 18 | chunk, range, unique, pluck, groupBy, sum |
random | 14 | Random.int, Random.uuid, Random.sample, Random.seed |
function | 17 | debounce, throttle, memoize, pipe, curry, once |
async | 11 | sleep, retry, timeout, pMap, pProps, pFilter, defer |
types | 16 | Path, PathValue, DeepPartial, Branded, Prettify |
lazy | 1 + variants | lazy, lazy.async, lazy.from, isLazy |
mixed | 4 | clone, areEqual, shuffle, coalesce |
Scope boundaries
| Concern | Lives in | Why |
|---|---|---|
Type/shape predicates (isString, isEmpty, isURL, …) | @mongez/supportive-is | Single-purpose package |
Array collection helpers (partition, keyBy, sortBy, …) | @mongez/collection | Richer collection model |
| HTML sanitization | Use DOMPurify | Parser-based, not regex |
| Schema validation | Use zod / valibot | Out of scope |
| Date manipulation | Use dayjs / date-fns / Temporal | Out of scope |