← All packages

@searsuite/sear-foundation-utils

General-purpose algorithms and guards without editor-domain ownership.

Column labels

functioncolumnIndexToLabel
columnIndexToLabel(columnIndex: number): string

Converts a zero-based column index to an Excel-style label (A, Z, AA, ...).

Example
columnIndexToLabel(0) // 'A'
columnIndexToLabel(26) // 'AA'
functioncolumnLabelToIndex
columnLabelToIndex(label: string): number

Converts an Excel-style column label (A, Z, AA, ...) to a zero-based index.

Example
columnLabelToIndex('A') // 0
columnLabelToIndex('AA') // 26

Colors

typeHexColor
type HexColor = templateLiteral
variableStandardColor
StandardColor: { Black: "#000000" }

Standard opaque colors shared by renderers and host adapters.

functiongetRandomColor
getRandomColor(): templateLiteral | null

Generates a random color in hexadecimal format. Ensures no duplicate colors until all colors are exhausted.

ReturnsA random hexadecimal color string, or null if all colors used.

functionreleaseColor
releaseColor(color: templateLiteral): boolean

Release a color back to the available pool

Numeric helpers

functionerf
erf(value: number): number

Evaluates erf without the error floor of short polynomial approximations.

functionerfc
erfc(value: number): number

Evaluates erfc directly in the positive tail to preserve small probabilities.

functionisFormulaError
isFormulaError<T>(value: T): value

Type guard for formula error-shaped values.

functionisFormulaText
isFormulaText<T>(value: T): value

Returns whether a value carries text-specific formula coercion semantics.

functionisNumber
isNumber(value: unknown): value

Returns whether a value is a JavaScript number.

functiontoNumberOrError
toNumberOrError(value: unknown): number | { code: "#VALUE!"; kind: "error" }

Converts a value for scalar arithmetic, returning an Excel #VALUE! error when invalid.

functiontoNumberOrZero
toNumberOrZero(value: unknown): number

Converts a formula value for aggregate functions; non-numeric values are 0.