import type { Complex, DimensionedQuantity } from './value-type'; import { ValueType } from './value-type'; export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity; /** * utility method * * @internal */ export declare const Is2DArray: (obj: undefined | T | T[] | T[][]) => obj is T[][]; export interface NumberUnion { type: ValueType.number; value: number; } export interface StringUnion { type: ValueType.string; value: string; } export interface ErrorUnion { type: ValueType.error; value: string; } export interface FormulaUnion { type: ValueType.formula; value: string; } export interface BooleanUnion { type: ValueType.boolean; value: boolean; } export interface ComplexUnion { type: ValueType.complex; value: Complex; } export interface DimensionedQuantityUnion { type: ValueType.dimensioned_quantity; value: DimensionedQuantity; } export interface UndefinedUnion { type: ValueType.undefined; value?: undefined; } export interface ExtendedUnion { type: ValueType.object; value: unknown; key?: string; /** adding a source field so we can track */ source?: string; } export interface FunctionUnion { type: ValueType.function; value: unknown; } export interface ArrayUnion { type: ValueType.array; value: UnionValue[][]; } /** switch to a discriminated union. implicit type guards! */ export type UnionValue = NumberUnion | ArrayUnion | ComplexUnion | DimensionedQuantityUnion | ExtendedUnion | StringUnion | FormulaUnion | UndefinedUnion | BooleanUnion | FunctionUnion | ErrorUnion; /** * shortcut, although this is wasteful * * @internal */ export declare const Box: (value: unknown, type?: ValueType) => UnionValue; /** * box a complex value in a union, potentially switching to a real if * there's no imaginary component. * * @internal */ export declare const ComplexOrReal: (value: Complex) => ComplexUnion | NumberUnion;