Skip to content

Add support for custom functions #37

Description

@wojciechczerniak

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIPublic methods and propertiesFeatureSomething we can add later on without introducing a breaking change

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions