UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

23 lines (18 loc) 670 B
import {BaseNamedFunction} from '../../../functions/_Base'; export interface NamedFunctionRegisterOptions { printWarnings?: boolean; } export class BaseNamedFunctionRegister { protected _functionByName: Map<string, typeof BaseNamedFunction> = new Map(); register(namedFunction: typeof BaseNamedFunction, options?: NamedFunctionRegisterOptions) { let printWarnings = options?.printWarnings; if (printWarnings == null) { printWarnings = true; } const type = namedFunction.type(); if (this._functionByName.has(type) && printWarnings) { console.warn(`namedFunction already registered`, type); } this._functionByName.set(type, namedFunction); } }