Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // {
- // "in1": "any",
- // "in2": "any",
- // "out": "boolean"
- // }
- // {
- // icon: function(ctx, props) {
- // },
- // execute: ComparatorGate
- // }
- function AndGate({ in1, in2 }) {
- return {
- out: in1 && in2
- };
- };
- function OrGate({ in1, in2 }) {
- return {
- out: in1 || in2
- };
- };
- function ComparatorGate({ in1, in2, comparator = '>' }) {
- return {
- out: in1 > in2
- };
- };
- function Delay({ time = 1000 } = {}) {
- return execute => {
- setTimeout(() => execute({ out: true }), time);
- };
- }
- console.log(AndGate({ in1: true, in2: true }));
- console.log(OrGate({ in1: true, in2: false }));
- console.log(ComparatorGate({ in1: 2, in2: 1 }));
- const comOut = Delay();
- if (typeof comOut === 'function') {
- const executor = (props) => {
- console.log('async execute', props);
- };
- const t = comOut(executor);
- }
- function ComparatorGateComponent() {
- return {
- executor: ComparatorGate,
- renderer: (ctx, props) => {
- ctx.fillText(props.comparator, 0, 0);
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement