UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

36 lines 1.08 kB
import { Node } from '../../programmatic/node.js'; import { NumberSchema } from '../../schemas/index.js'; export default class NodeDefinition extends Node { static title = 'Clamp'; static type = 'studio.tokens.math.clamp'; static description = 'Clamp node allows you to restricts a value within a specified minimum and maximum range.'; constructor(props) { super(props); this.addInput('value', { type: { ...NumberSchema, default: 0 } }); this.addInput('min', { type: { ...NumberSchema, default: 0 } }); this.addInput('max', { type: { ...NumberSchema, default: 0 } }); this.addOutput('value', { type: NumberSchema }); } execute() { const { value, min, max } = this.getAllInputs(); this.outputs.value.set(value > max ? max : value < min ? min : value); } } //# sourceMappingURL=clamp.js.map