mirror of
https://github.com/docmost/docmost.git
synced 2026-08-29 10:05:03 +08:00
feat(base-formula): add function registry register helper
This commit is contained in:
@@ -12,3 +12,10 @@ export type FormulaFn = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const registry: Map<string, FormulaFn> = new Map();
|
export const registry: Map<string, FormulaFn> = new Map();
|
||||||
|
|
||||||
|
export function register(fn: FormulaFn): void {
|
||||||
|
if (registry.has(fn.name)) {
|
||||||
|
throw new Error(`Duplicate formula function: ${fn.name}`);
|
||||||
|
}
|
||||||
|
registry.set(fn.name, fn);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ export * from "./parser";
|
|||||||
export * from "./resolver";
|
export * from "./resolver";
|
||||||
export * from "./typecheck";
|
export * from "./typecheck";
|
||||||
export * from "./format";
|
export * from "./format";
|
||||||
export { registry } from "./functions/registry";
|
export { registry, register } from "./functions/registry";
|
||||||
export type { FormulaFn } from "./functions/registry";
|
export type { FormulaFn } from "./functions/registry";
|
||||||
export * from "./graph";
|
export * from "./graph";
|
||||||
|
|||||||
Reference in New Issue
Block a user