MCPcopy Create free account
hub / github.com/pmndrs/leva / sanitize

Function sanitize

packages/plugin-plot/src/plot-plugin.ts:6–19  ·  view source on GitHub ↗
(
  expression: string,
  _settings: InternalPlotSettings,
  _prevValue: math.MathNode,
  _path: string,
  store: StoreType
)

Source from the content-addressed store, hash-verified

4import type { PlotInput, InternalPlot, InternalPlotSettings } from './plot-types'
5
6export const sanitize = (
7 expression: string,
8 _settings: InternalPlotSettings,
9 _prevValue: math.MathNode,
10 _path: string,
11 store: StoreType
12) => {
13 if (expression === '') throw Error('Empty mathjs expression')
14 try {
15 return parseExpression(expression, store.get)
16 } catch (e) {
17 throw Error('Invalid mathjs expression string')
18 }
19}
20
21export const format = (value: InternalPlot) => {
22 return value.__parsed.toString()

Callers

nothing calls this directly

Calls 1

parseExpressionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…