Skip to content

Instance Methods

Inspect the registry, remove extensions, and clear caches without rebuilding the entire instance.

MethodReturnsDescription
use(plugin)thisApply a plugin immediately and return the same instance for chaining.
addTransform(name, fn)thisRegister or replace a transform.
addFunction(name, fn)thisRegister or replace a pure function.
addContextFunction(name, fn)thisRegister or replace a context-aware function. Shares a namespace with addFunction.
removeTransform(name)booleanUnregister a transform. Returns true if it existed.
removeFunction(name)booleanUnregister a function (pure or context-aware). Returns true if it existed.
hasTransform(name)booleanCheck if a transform is registered.
hasFunction(name)booleanCheck if a function (pure or context-aware) is registered.
isContextFunction(name)booleanCheck whether a registered function reads the evaluation context.
listTransforms()string[]List all registered transform names.
listFunctions()string[]List all registered function names (both pure and context-aware).
clearCache()voidClear the internal AST cache and compiled-expression cache.
ts
const expr = bonsai().use(strings)

expr.hasTransform('upper')    // true
expr.listTransforms()          // ["upper", "lower", "trim", ...]

expr.removeTransform('upper') // true
expr.hasTransform('upper')    // false

expr.clearCache()              // clear AST + compiled caches