@ooneex/utils is a collection of tiny, single-purpose helper functions you reach for again and again: case converters, time formatters, random ID generators, a string parser, a minimal translator, and a few odds and ends. Each helper is exported from its own subpath so you only pull in what you use.
Installation
Add the package with Bun.Usage
Every helper is imported from a dedicated subpath (@ooneex/utils/<name>).
String and case helpers
Convert strings between cases, capitalize a single word, split a string into words, or trim arbitrary characters.Parsing helpers
parseString coerces a string into its natural type (number, boolean, null, array, or JSON). parseEnvVars runs the same coercion over an env object while camel-casing the keys.
Time helpers
Format durations for display, or pause an async flow withsleep.
Numbers and IDs
Format large numbers compactly and generate random identifiers (backed bynanoid).
Translations
trans resolves a dotted key from a nested dictionary, with locale fallback, pluralization (_zero / _plural), and {{ param }} interpolation. It returns a tagged result so you can branch on misses.
Browser helper
dataURLtoFile turns a base64 data URL (e.g. from a canvas or file reader) into a File instance.
When to use it
- You need consistent case conversion (
toCamelCase,toKebabCase, etc.) for keys, slugs, identifiers, or class names. - You want to coerce string config or query values into real types with
parseString, or normalize an env object withparseEnvVars. - You’re formatting durations or large numbers for the UI, or need a quick
await sleep(ms)in async code. - You need short, URL-safe random IDs without pulling in a full UUID library.
- You want a lightweight, dependency-free translation lookup with plurals and interpolation instead of a heavy i18n framework.
- You don’t need it for heavy text processing or full internationalization — reach for a dedicated i18n/NLP library when requirements grow beyond these helpers.