@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
37 lines • 1.1 kB
JavaScript
import { AnySchema, NumberSchema } from '../../schemas/index.js';
import { Node } from '../../programmatic/node.js';
/**
* A node that passes through the input to the output.
*/
export default class NodeDefinition extends Node {
static title = 'Delay';
static type = 'studio.tokens.generic.delay';
static description = 'When trigger, it will output the provided value after a delay';
_interval = null;
constructor(props) {
super(props);
this.addInput('value', {
type: AnySchema
});
this.addInput('delay', {
type: {
...NumberSchema,
default: 1000
}
});
this.addOutput('value', {
type: AnySchema
});
}
async execute() {
const { delay } = this.getAllInputs();
const raw = this.inputs.value;
return new Promise(resolve => {
setTimeout(() => {
this.outputs.value.set(raw.value, raw.type);
resolve();
}, delay);
});
}
}
//# sourceMappingURL=delay.js.map