UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

34 lines 1.08 kB
import { Node } from '../../programmatic/node.js'; import { StringSchema } from '../../schemas/index.js'; /** * This node replaces all occurrences of a search string with a replacement string */ export default class NodeDefinition extends Node { static title = 'Replace'; static type = 'studio.tokens.string.replace'; static description = 'Replaces all occurrences of a search string with a replacement string'; constructor(props) { super(props); this.addInput('string', { type: StringSchema }); this.addInput('search', { type: StringSchema }); this.addInput('replace', { type: { ...StringSchema, default: '' } }); this.addOutput('string', { type: StringSchema }); } execute() { const { string, search, replace } = this.getAllInputs(); const result = string.split(search).join(replace); this.outputs.string.set(result); } } //# sourceMappingURL=replace.js.map