Description
Spec requires that the user is able to implement external functions listed in #14. We have to provide public methods and a mechanism to register custom functions. Custom functions should be structured the same as built-in functions #43 and described with the same metadata as build-in functions #2
API proposal
public static registerFormula(id: string, formula: FormulaDefinition): void;
public static getFormula(id: string): FormulaDefinition;
public static getFormulas(): string[];
Usa case
import { HyperFormula } from 'hyperformula';
import { CustomSum } from './myFormulas/customSUM';
Hyperformula.registerFormulas(CustomSum);
Customizing loaded formulas
It should be possible to initialize HyperFormula with a subset of built-in formulas:
import { HyperFormula } from 'hyperformula/core'
import { Trigonometry } from `hyperformula/plugins/trigonometry`
import { CustomSum } from './myFormulas/customSUM';
HyperFormula.registerFormulas(Trigonometry)
HyperFormula.registerFormulas(CustomSum)
Aliasing
ODFF recommends keeping all functions namespaced. Therefore all functions implemented by us should be named with HYPERFORMULA. prefix. ie: HYPERFORMULA.COS, HYPERFORMULA.SUM. And then aliased to common names: COS, SUM. It will be easy then to overwrite some of them with custom implementation just by aliasing different namespaced functions: MYOWN.SUM to canonical SUM name.
Description
Spec requires that the user is able to implement external functions listed in #14. We have to provide public methods and a mechanism to register custom functions. Custom functions should be structured the same as built-in functions #43 and described with the same metadata as build-in functions #2
API proposal
Usa case
Customizing loaded formulas
It should be possible to initialize HyperFormula with a subset of built-in formulas:
Aliasing
ODFF recommends keeping all functions namespaced. Therefore all functions implemented by us should be named with
HYPERFORMULA.prefix. ie:HYPERFORMULA.COS,HYPERFORMULA.SUM. And then aliased to common names:COS,SUM. It will be easy then to overwrite some of them with custom implementation just by aliasing different namespaced functions:MYOWN.SUMto canonicalSUMname.