daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Jun 20th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // created by crodas -- Public domain
  2.  
  3. // private, number of running processes
  4. var running = 0;
  5.  
  6. // sort of try time
  7. exports.time  = 10;
  8. // limit, max 5 running processes
  9. exports.limit = 5;
  10.  
  11. exports.exec = function(callback) {
  12.     if (typeof callback != "function") {
  13.         throw ("callback is not a valid function");
  14.     }
  15.     var i = setInterval(function() {
  16.         if (running < exports.limit) {
  17.             running++;
  18.             callback();
  19.             running--;
  20.             clearInterval(i);
  21.         }
  22.     }, exports.time);
  23. };
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
 
Top