UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

41 lines 1.19 kB
import { Node } from '../../programmatic/node.js'; import { StringSchema } from '../../schemas/index.js'; export default class NodeDefinition extends Node { static title = 'Regex'; static type = 'studio.tokens.string.regex'; static description = 'Replaces a string with a regex'; constructor(props) { super(props); this.addInput('input', { type: StringSchema }); this.addInput('match', { type: { ...StringSchema, default: '' } }); this.addInput('flags', { type: { ...StringSchema, default: '' } }); this.addInput('replace', { type: { ...StringSchema, default: '' } }); this.addOutput('value', { type: StringSchema }); } execute() { const { input, match, flags, replace } = this.getAllInputs(); const regex = new RegExp(match, flags); const output = input.replace(regex, replace); this.outputs.value.set(output); } } //# sourceMappingURL=regex.js.map