Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement