SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // {
  2. //   "in1": "any",
  3. //   "in2": "any",
  4. //   "out": "boolean"
  5. // }
  6.  
  7. // {
  8. //   icon: function(ctx, props) {
  9.  
  10. //   },
  11. //   execute: ComparatorGate
  12. // }
  13.  
  14. function AndGate({ in1, in2 }) {
  15.   return {
  16.     out: in1 && in2
  17.   };
  18. };
  19.  
  20. function OrGate({ in1, in2 }) {
  21.   return {
  22.     out: in1 || in2
  23.   };
  24. };
  25.  
  26. function ComparatorGate({ in1, in2, comparator = '>' }) {
  27.   return {
  28.     out: in1 > in2
  29.   };
  30. };
  31.  
  32. function Delay({ time = 1000 } = {}) {
  33.   return execute => {
  34.     setTimeout(() => execute({ out: true }), time);
  35.   };
  36. }
  37.  
  38. console.log(AndGate({ in1: true, in2: true }));
  39. console.log(OrGate({ in1: true, in2: false }));
  40. console.log(ComparatorGate({ in1: 2, in2: 1 }));
  41.  
  42. const comOut = Delay();
  43.  
  44. if (typeof comOut === 'function') {
  45.   const executor = (props) => {
  46.     console.log('async execute', props);
  47.   };
  48.   const t = comOut(executor);
  49. }
  50.  
  51.  
  52. function ComparatorGateComponent() {
  53.   return {
  54.     executor: ComparatorGate,
  55.     renderer: (ctx, props) => {
  56.       ctx.fillText(props.comparator, 0, 0);
  57.     }
  58.   };
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top