'use strict';

module.exports = (api) => {

  api.metasync.throttle = (
    // Function throttling
    timeout, // time interval
    fn, // function to be executed once per timeout
    args // arguments array for fn (optional)
  ) => {
    let timer = null;
    let wait = false;
    return function throttled() {
      if (!timer) {
        timer = setTimeout(() => {
          timer = null;
          if (wait) throttled();
        }, timeout);
        if (args) fn(...args);
        else fn();
        wait = false;
      } else {
        wait = true;
      }
    };
  };

  api.metasync.debounce = (
    timeout,
    fn,
    args = []
  ) => {
    let timer;
    return () => {
      clearTimeout(timer);
      timer = setTimeout(() => fn(...args), timeout);
    };
  };

  api.metasync.timeout = (
    // Set timeout for function execution
    timeout, // time interval
    asyncFunction, // async function to be executed
    // done - callback function
    done // callback function on done
  ) => {
    let finished = false;
    done = api.metasync.cb(done);

    const timer = setTimeout(() => {
      if (!finished) {
        finished = true;
        done(null);
      }
    }, timeout);

    asyncFunction((err, data) => {
      if (!finished) {
        clearTimeout(timer);
        finished = true;
        done(err, data);
      }
    });
  };

};

@@ -1101,33 +1101,8 @@
 %3E %7B%0A
-      if (!finished) %7B%0A  
     
@@ -1112,34 +1112,32 @@
 inished = true;%0A
-  
       done(null)
@@ -1138,24 +1138,16 @@
 (null);%0A
-      %7D%0A
     %7D, t

Remove redundant condition