@gg-software/utils
Pure, framework-agnostic helpers. No React, no DOM requirements (unless noted).
pnpm add @gg-software/utils🚧 This package is growing — helpers for strings, numbers, dates, arrays, objects, validation, async and ids are planned. Documented below is what ships today.
cx
Join class names conditionally. Accepts strings, numbers, nested arrays and
{ className: condition } objects; falsy values are skipped.
import { cx } from '@gg-software/utils';
cx('btn', isActive && 'btn--active', { 'btn--lg': large });
// → "btn btn--active btn--lg"
cx(['a', ['b', null]], 0, undefined, 'c');
// → "a b c"Signature
function cx(...values: ClassValue[]): string;
type ClassValue =
| string
| number
| null
| false
| undefined
| ClassValue[]
| Record<string, boolean | null | undefined>;| Parameter | Type | Description |
|---|---|---|
...values | ClassValue[] | any mix of strings, numbers, arrays and condition objects |
| returns | string | space-joined class list |
numberToString
Convert a number to its string representation, optionally in another base.
import { numberToString } from '@gg-software/utils';
numberToString(42); // "42"
numberToString(255, 16); // "ff"Signature
function numberToString(value: number, radix?: number): string;| Parameter | Type | Default | Description |
|---|---|---|---|
value | number | — | the number to convert |
radix | number | 10 | base (2–36) to format the number in |
| returns | string | the number formatted as a string |