UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

30 lines 948 B
import { AnySchema, BooleanSchema } from '../../schemas/index.js'; import { Node } from '../../programmatic/node.js'; export default class NodeDefinition extends Node { static title = 'If'; static type = 'studio.tokens.logic.if'; static description = 'If node allows you to conditionally choose a value based on a condition.'; constructor(props) { super(props); this.addInput('condition', { type: BooleanSchema }); this.addInput('a', { type: AnySchema }); this.addInput('b', { type: AnySchema }); this.addOutput('value', { type: AnySchema }); } execute() { const { condition } = this.getAllInputs(); const a = this.inputs.a; const b = this.inputs.b; const val = condition ? a : b; this.outputs.value.set(val.value, val.type); } } //# sourceMappingURL=if.js.map