@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
23 lines • 806 B
JavaScript
import { AnyArraySchema } from '../../schemas/index.js';
import { Node } from '../../programmatic/node.js';
export default class NodeDefinition extends Node {
static title = 'Reverse Array';
static type = 'studio.tokens.array.reverse';
static description = 'Reverses a given array without mutating the original';
constructor(props) {
super(props);
this.addInput('array', {
type: AnyArraySchema
});
this.addOutput('value', {
type: AnyArraySchema
});
}
execute() {
const array = this.inputs.array;
//Normal reverse mutates the array. We don't want that.
const reversed = [...array.value].reverse();
this.outputs.value.set(reversed, array.type);
}
}
//# sourceMappingURL=reverse.js.map