@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
31 lines • 1.02 kB
JavaScript
import { Node } from '../../programmatic/node.js';
import { NumberSchema } from '../../schemas/index.js';
import { setToPrecision } from '../../utils/precision.js';
export default class NodeDefinition extends Node {
static title = 'Round';
static type = 'studio.tokens.math.round';
static description = 'Round node allows you to adjusts a floating-point number to the nearest integer or to a specified precision.';
constructor(props) {
super(props);
this.addInput('value', {
type: {
...NumberSchema,
default: 0
}
});
this.addInput('precision', {
type: {
...NumberSchema,
default: 0
}
});
this.addOutput('value', {
type: NumberSchema
});
}
execute() {
const { precision, value } = this.getAllInputs();
this.outputs.value.set(setToPrecision(value, precision));
}
}
//# sourceMappingURL=round.js.map