@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
26 lines • 863 B
JavaScript
import { AnyArraySchema, AnySchema } from '../../schemas/index.js';
import { Node } from '../../programmatic/node.js';
export default class NodeDefinition extends Node {
static title = 'Array push';
static type = 'studio.tokens.array.push';
static description = 'Pushes an item to an array and returns the new array.';
constructor(props) {
super(props);
this.addInput('array', {
type: AnyArraySchema
});
this.addInput('item', {
type: AnySchema
});
this.addOutput('value', {
type: AnyArraySchema
});
}
execute() {
const { item } = this.getAllInputs();
const array = this.inputs.array;
const calculated = [...array.value, item];
this.outputs.value.set(calculated, array.type);
}
}
//# sourceMappingURL=push.js.map