Reference
This section documents the complete public surface of @samline/formatter. Start with the API for method signatures, then use the focused references for configuration, regex, types, entrypoints, and the browser global.
Sections in this reference
Section titled “Sections in this reference”- Configuration — every
FormatOptionsfield, with defaults and per-formatTypebehavior. - API — function-by-function signatures, exported types, advanced helpers, and a side-effects-per-function lookup table.
- Regex — bundled validation patterns paired with ready-to-use error messages, with the parametric variants.
- TypeScript — every exported type —
FormatType,FormatterResult,FormatOptions,RegexKey,RegexEntry,Regex, the parametric signatures. - Entrypoints — ESM / CJS / browser module /
/vanillaalias distribution matrix. - Browser — the
window.FormatterIIFE for no-bundler setups (Shopify, WordPress, classic templates). - Recipes — task-oriented recipes for common real-world scenarios.
For presentation and interaction concerns, see Styling and UX. Formatter returns strings and intentionally leaves CSS, validation state, and caret management to the caller.