UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

33 lines 1 kB
import { Node } from '../../programmatic/node.js'; import { StringSchema } from '../../schemas/index.js'; import { arrayOf } from '../../schemas/utils.js'; export default class NodeDefinition extends Node { static title = 'Split String'; static type = 'studio.tokens.string.split'; static description = 'Converts a string to lowercase'; constructor(props) { super(props); this.addInput('value', { type: StringSchema }); this.addInput('separator', { type: { ...StringSchema, default: ',' } }); this.addOutput('value', { type: arrayOf(StringSchema) }); } execute() { const { value, separator } = this.getAllInputs(); if (separator === undefined) { this.outputs.value.set([value]); } else { this.outputs.value.set(value.split(separator)); } } } //# sourceMappingURL=split.js.map