anyfamily
v1.0.2
Published
The whole any* family in one install — anywhen, anyamount, anymany, anyaround and anylong: micro Intl formatters with zero dependencies of their own.
Maintainers
Readme
a*
anyfamily — install one, get five. The whole any* family — micro Intl-powered
formatters, each with zero dependencies of its own — behind a single import.
npm install anyfamilyimport { anywhen, anyamount, anymany, anyaround, anylong } from "anyfamily";ESM + CJS, fully typed, sideEffects: false — bundlers tree-shake away
whatever you don't use.
anywhen — dates & relative time
Tiny smart date formatter: relative when near, calendar labels for recent days, absolute when far. npm
anywhen(new Date(Date.now() - 3 * 3600 * 1000), { mode: "relative", locale: "en" });
// "3 hours ago"anyamount — currency, numbers & units
Tiny smart number formatter: compact notation, currency, and sanctioned units, any locale. npm
anyamount(1999, { mode: "currency", currency: "EUR", locale: "en" });
// "€1,999.00"anymany — localized lists
Smart list formatter: sort and join arrays of strings the way each locale expects. npm
anymany(["banana", "apple", "cherry"], { locale: "en" });
// "banana, apple, and cherry"anyaround — region & language names + flags
Micro locale display: any region, language, script, currency or calendar code to its localized name, with country flags. npm
anyaround("US", { display: "flag-name", locale: "en" });
// "🇺🇸 United States"anylong — durations
Any duration in — a number, two Dates, an ISO 8601 string, shorthand, or a
duration record — into a localized string, over Intl.DurationFormat.
npm
anylong("PT2H30M", { locale: "en" });
// "2 hr, 30 min"types
Every public type from all five packages is re-exported. Names that collide
across packages (Mode, Style, SmartOptions, CurrencyOptions) carry
their package prefix — AnywhenMode, AnyamountStyle,
AnyaroundCurrencyOptions, … Locale is structurally identical in
anywhen/anyamount/anymany/anyaround/anylong and exported once.
license
MIT © kirilinsky
