hyperformula
Version:
HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas
78 lines (77 loc) • 3.6 kB
TypeScript
/**
* @license
* Copyright (c) 2025 Handsoncode. All rights reserved.
*/
import { ProcedureAst } from '../../parser';
import { InterpreterState } from '../InterpreterState';
import { InterpreterValue } from '../InterpreterValue';
import { FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions } from './FunctionPlugin';
/**
* Interpreter plugin containing text-specific functions
*/
export declare class TextPlugin extends FunctionPlugin implements FunctionPluginTypecheck<TextPlugin> {
static implementedFunctions: ImplementedFunctions;
/**
* Corresponds to CONCATENATE(value1, [value2, ...])
*
* Concatenates provided arguments to one string.
*
* @param {ProcedureAst} ast - The procedure AST node
* @param {InterpreterState} state - The interpreter state
*/
concatenate(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
/**
* Corresponds to SPLIT(string, index)
*
* Splits provided string using space separator and returns chunk at zero-based position specified by second argument
*
* @param {ProcedureAst} ast - The procedure AST node
* @param {InterpreterState} state - The interpreter state
*/
split(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
len(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
lower(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
trim(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
proper(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
clean(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
exact(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
rept(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
right(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
left(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
mid(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
replace(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
search(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
substitute(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
find(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
t(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
/**
* Corresponds to N(value)
*
* Converts a value to a number according to Excel specification:
* - Numbers return themselves
* - Dates return their serial number (stored as numbers internally)
* - TRUE returns 1, FALSE returns 0
* - Error values propagate
* - Anything else (text, empty) returns 0
* - For ranges, uses the first cell value
*/
n(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
upper(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
/**
* Corresponds to VALUE(text)
*
* Converts a text string that represents a number to a number.
*
* @param {ProcedureAst} ast - The procedure AST node
* @param {InterpreterState} state - The interpreter state
*/
value(ast: ProcedureAst, state: InterpreterState): InterpreterValue;
/**
* Parses a string to a numeric value, handling whitespace trimming and empty string validation.
*
* @param {string} input - The string to parse
* @returns {Maybe<ExtendedNumber>} The parsed number or undefined if parsing fails or input is empty
*/
private parseStringToNumber;
private escapeRegExpSpecialCharacters;
}