UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

25 lines 816 B
import { Node } from '../../programmatic/node.js'; import { NumberSchema, StringSchema } from '../../schemas/index.js'; export default class NodeDefinition extends Node { static title = 'Parse Number'; static type = 'studio.tokens.typing.parseNumber'; static description = 'Converts a string to a number'; constructor(props) { super(props); this.addInput('value', { type: StringSchema }); this.addOutput('value', { type: NumberSchema }); } execute() { const { value } = this.getAllInputs(); const parsed = Number(value); if (isNaN(parsed)) { throw new Error('Could not parse string to number'); } this.outputs.value.set(parsed); } } //# sourceMappingURL=parseNumber.js.map