SHARE
TWEET

Untitled

a guest Apr 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const cron = require("node-cron");
  2.  
  3. let queue = getItems();
  4. console.log("Queued", queue);
  5.  
  6. function getItems() {
  7.   return Array(10).fill(0).map(i => Math.floor(Math.random() * 100))
  8. }
  9.  
  10. cron.schedule("* * * * *", () => {
  11.   queue = getItems();
  12.   console.log("Queued", queue);  
  13. });
  14.  
  15. cron.schedule("*/5 * * * * *", () => {
  16.   item = queue.splice(0, 1);
  17.   console.log("Executing", item);
  18. });
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