@mysetup/helpers
v2.0.10
Published
Shared utility helpers for browser and server applications.
Downloads
578
Maintainers
Readme
@mysetup/helpers
Shared utility helpers for browser and server applications.
Installation
pnpm add @mysetup/helpersSupported libraries and runtimes
| Supported | Notes |
| ----------------- | ------------------------------------------------------------- |
| Vite | Root exports are supported |
| Next.js | Root exports are supported; crypto helpers are server-only |
| Node.js | Full support including @mysetup/helpers/crypto |
| Browser-only APIs | getTextWidth and setCookie should only run in the browser |
Browser and universal usage
import {
formatPhoneNumber,
generateCacheKey,
getDateTimeDiff,
} from "@mysetup/helpers";
const formatted = formatPhoneNumber("9876543210");
const cacheKey = generateCacheKey("brand", "production", "users");
const diff = getDateTimeDiff("2025-01-01T00:00:00Z");Node.js only usage
import { decodeData, encodeData } from "@mysetup/helpers/crypto";
const encrypted = encodeData("hello", process.env.DATA_KEY || "");
const decrypted = decodeData(encrypted, process.env.DATA_KEY || "");Notes
getTextWidthandsetCookieshould only be called in the browser.encodeDataanddecodeDatashould only be used in Node.js or other runtimes that expose the Nodecryptomodule.
