Skip to Content
Utils

@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>;
ParameterTypeDescription
...valuesClassValue[]any mix of strings, numbers, arrays and condition objects
returnsstringspace-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;
ParameterTypeDefaultDescription
valuenumberthe number to convert
radixnumber10base (2–36) to format the number in
returnsstringthe number formatted as a string