@workstudio/utilities
v1.0.1
Published
Utility Functions for WorkStudio Platform
Maintainers
Readme
Workstudio — Utilities (Node)
Small collection of lightweight TypeScript utility functions used across Workstudio projects.
This package exposes a few focused helpers under src/utils/:
random— random booleans, integers, floats, UUIDs, and secure stringsformatter— date and currency formatting helpersconverter— base64 / URL helpers and a small hashing helper
Usage
During development you can import directly from src:
import { randomUUID, randomString } from './src/utils/random';
import { formatDate, formatCurrency } from './src/utils/formatter';
import { base64Encode, base64Decode } from './src/utils/converter';
console.log(randomUUID());
console.log(formatDate(new Date()));
console.log(base64Encode({ hello: 'world' }));Exported helpers
randomBoolean(probability?: number): boolean— random boolean with optional probability of true (0..1)randomInteger(min?: number, max?: number): number— integer in inclusive rangerandomFloat(min?: number, max?: number): number— float in [min, max)randomUUID(): string— cryptographically generated UUIDrandomString(bytes?: number): string— secure hex string (bytes * 2 length)formatDate(date, locale?)— formats Date/ISO/timestamp to long human dateformatCurrency(amount, currency?, locale?)— formats number as currencybase64Encode(value)— base64 encode, JSON-stringifies objectsbase64Decode(str)— base64 decode and attempt JSON.parse, falls back to stringurlEncode/urlDecode— wrappers around encodeURIComponent / decodeURIComponenthash(value, alg?)— return hex digest (default sha256)
Development
Run TypeScript checks / build from the package root:
pnpm install
pnpm run buildpnpm run build will compile to dist/ using the local tsconfig.json.
Contributing
Small, well-scoped improvements are welcome. Preferred changes:
- Add unit tests for helpers you modify
- Keep runtime dependencies minimal
License
MIT — see package.json for details.
