clever-queue 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +111 -16
  2. package/dist/engine/index.d.ts +1 -1
  3. package/dist/engine/index.js +2 -2
  4. package/dist/engine/index.js.map +1 -1
  5. package/dist/helpers/errors.js +1 -1
  6. package/dist/helpers/errors.js.map +1 -1
  7. package/dist/queues/index.d.ts +1 -1
  8. package/dist/queues/index.js +13 -2
  9. package/dist/queues/index.js.map +1 -1
  10. package/dist/queues/interfaces.d.ts +1 -1
  11. package/dist/queues/interfaces.js +10 -2
  12. package/dist/queues/interfaces.js.map +1 -1
  13. package/dist/runners/index.d.ts +1 -1
  14. package/dist/runners/index.js +1 -1
  15. package/dist/runners/index.js.map +1 -1
  16. package/dist/tasks/index.d.ts +1 -1
  17. package/dist/tasks/index.js +2 -2
  18. package/dist/tasks/index.js.map +1 -1
  19. package/documentation/demo_1E_2Q_1R_8T_Weight.svg +1 -0
  20. package/documentation/demo_1E_2Q_2R_8T_ProrityRunner.svg +1 -0
  21. package/documentation/demo_1E_3Q_1R_12T_Priority.svg +1 -0
  22. package/examples/src/demo_1E_2Q_1R_8T_Weight.ts +40 -0
  23. package/examples/src/demo_1E_2Q_2R_8T_ProrityRunner.ts +41 -0
  24. package/examples/src/demo_1E_3Q_1R_12T_Priority.ts +45 -0
  25. package/examples/src/example00.ts +1 -1
  26. package/examples/src/helpers/animations.ts +2 -2
  27. package/examples/src/path-expression-matcher.d.ts +6 -0
  28. package/package.json +2 -2
  29. package/src/engine/index.ts +3 -3
  30. package/src/helpers/errors.ts +1 -1
  31. package/src/queues/index.ts +11 -3
  32. package/src/queues/interfaces.ts +16 -3
  33. package/src/runners/index.ts +2 -2
  34. package/src/tasks/index.ts +3 -3
  35. package/test/behavior/scheduler.mjs +124 -0
  36. package/test/issues/00008-error-contract.mjs +52 -0
  37. package/test/issues/00009-weight-semantics.mjs +54 -0
  38. package/test/issues/00010-lifecycle-semantics.mjs +101 -0
  39. package/test/issues/00012-wording-cleanup.mjs +30 -0
  40. package/test/miscellaneous/test.mjs +16 -9
  41. package/test/units/engine.mjs +2 -2
  42. package/test/units/queue.mjs +4 -4
  43. package/test/units/task.mjs +13 -12
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="800" height="800"><g><rect x="10" y="10" width="10" height="10"></rect><animateMotion id="start" begin="stop.end;0" dur="2" path="M400,-800"></animateMotion></g><g id="1962bcb6f3"><g><rect x="125" y="100" width="100" height="350" rx="20" ry="20" fill="lightblue" stroke="blue" stroke-width="5"></rect></g></g><g id="20fb35da46"><g><rect x="350" y="100" width="100" height="350" rx="20" ry="20" fill="lightblue" stroke="blue" stroke-width="5"></rect></g></g><g id="87263d9a52"><g><rect x="575" y="100" width="100" height="350" rx="20" ry="20" fill="lightblue" stroke="blue" stroke-width="5"></rect></g></g><g id="7972c7f4d2"><g><rect x="350" y="610" width="100" height="100" rx="20" ry="20" fill="lightgreen" stroke="green" stroke-width="5"></rect></g></g><g id="task A1"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task A1</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L135,360"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M135,360 L360,620"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task A2"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task A2</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L135,277"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M135,277 L135,277"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M135,277 L135,277"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M135,277 L135,360"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M135,360 L360,620"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task A3"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task A3</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L135,193"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M135,193 L135,193"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M135,193 L135,193"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M135,193 L135,270"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M135,270 L135,270"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M135,270 L135,360"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M135,360 L360,620"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task A4"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task A4</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L135,110"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M135,110 L135,110"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M135,110 L135,110"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M135,110 L135,180"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M135,180 L135,180"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M135,180 L135,270"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M135,270 L135,270"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M135,270 L135,270"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M135,270 L135,360"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M135,360 L135,360"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M135,360 L360,620"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task B1"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task B1</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L360,360"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,360 L360,620"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task B2"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task B2</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L360,277"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,277 L360,277"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,277 L360,360"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,360 L360,620"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task B3"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task B3</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L360,193"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,193 L360,193"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,193 L360,270"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,270 L360,270"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,270 L360,360"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,360 L360,620"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task B4"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task B4</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L360,110"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M360,110 L360,110"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M360,110 L360,180"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M360,180 L360,180"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M360,180 L360,270"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M360,270 L360,270"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M360,270 L360,270"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M360,270 L360,360"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M360,360 L360,360"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M360,360 L360,620"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task C1"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task C1</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L585,360"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M585,360 L360,620"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task C2"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task C2</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L585,277"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M585,277 L585,277"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M585,277 L585,360"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M585,360 L360,620"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task C3"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task C3</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L585,193"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M585,193 L585,193"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M585,193 L585,270"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M585,270 L585,270"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M585,270 L585,360"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M585,360 L360,620"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g id="task C4"><g><rect width="80" height="80" rx="20" ry="20" fill="blue"></rect><rect width="20" height="10" rx="20" ry="20" fill="green"></rect><text dx="40" dy="40" dominant-baseline="middle" text-anchor="middle" fill="white">task C4</text></g><animateMotion begin="0" dur="0" path="M360,-80"></animateMotion><animateMotion begin="start.end+1s" dur="1" path="M360,-80 L585,110"></animateMotion><animateMotion begin="start.end+2s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+3s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+4s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+5s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+6s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+7s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+8s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+9s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+10s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+11s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+12s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+13s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+14s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+15s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+16s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+17s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+18s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+19s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+20s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+21s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+22s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+23s" dur="1" path="M585,110 L585,110"></animateMotion><animateMotion begin="start.end+24s" dur="1" path="M585,110 L585,180"></animateMotion><animateMotion begin="start.end+25s" dur="1" path="M585,180 L585,180"></animateMotion><animateMotion begin="start.end+26s" dur="1" path="M585,180 L585,270"></animateMotion><animateMotion begin="start.end+27s" dur="1" path="M585,270 L585,270"></animateMotion><animateMotion begin="start.end+28s" dur="1" path="M585,270 L585,270"></animateMotion><animateMotion begin="start.end+29s" dur="1" path="M585,270 L585,360"></animateMotion><animateMotion begin="start.end+30s" dur="1" path="M585,360 L585,360"></animateMotion><animateMotion begin="start.end+31s" dur="1" path="M585,360 L360,620"></animateMotion><animateMotion begin="start.end+32s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+33s" dur="1" path="M360,620 L360,620"></animateMotion><animateMotion begin="start.end+34s" dur="1" path="M360,620 L360,870"></animateMotion><animateMotion begin="start.end+35s" dur="1" path="M360,870 L360,870"></animateMotion><animateMotion begin="start.end+36s" dur="1" path="M360,870 L360,870"></animateMotion></g><g><rect x="10" y="10" width="10" height="10"></rect><animateMotion id="stop" begin="start.end + 36s" dur="2" path="M400,-800"></animateMotion></g></svg>
@@ -0,0 +1,40 @@
1
+ import { animations, myAsyncTaskToExecute } from "./helpers";
2
+ import * as cleverQueue from "clever-queue";
3
+
4
+ async function run(): Promise<void> {
5
+ const engine = cleverQueue.createEngine({ autostart: false });
6
+ const queueA = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 2 }); // Same priority (128) as queueB, but higher weight (2 vs 1)
7
+ const queueB = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 1 });
8
+
9
+ const tasks: cleverQueue.tasks.Task[] = [];
10
+ const promiseList: Promise<unknown>[] = [];
11
+
12
+ const tasksList: { id: string; timeout: number; queue: cleverQueue.queues.Queue }[] = [
13
+ { id: "task A1", timeout: 2500, queue: queueA },
14
+ { id: "task A2", timeout: 2500, queue: queueA },
15
+ { id: "task A3", timeout: 2500, queue: queueA },
16
+ { id: "task A4", timeout: 2500, queue: queueA },
17
+ { id: "task B1", timeout: 2500, queue: queueB },
18
+ { id: "task B2", timeout: 2500, queue: queueB },
19
+ { id: "task B3", timeout: 2500, queue: queueB },
20
+ { id: "task B4", timeout: 2500, queue: queueB },
21
+ ];
22
+
23
+ for (const taskInfo of tasksList) {
24
+ const task = engine.createTask(() => myAsyncTaskToExecute(taskInfo.id, taskInfo.timeout), { id: taskInfo.id });
25
+ tasks.push(task);
26
+ promiseList.push(taskInfo.queue.enqueue(task));
27
+ }
28
+
29
+ const anim = new animations.Animation(engine, tasks, "./documentation/" + __filename.slice(__dirname.length + 1, -3) + ".svg");
30
+
31
+ await anim.start()
32
+ engine.start();
33
+ await Promise.all(promiseList);
34
+ engine.stop();
35
+ await anim.stop();
36
+ }
37
+
38
+ (async () => {
39
+ await run();
40
+ })();
@@ -0,0 +1,41 @@
1
+ import { animations, myAsyncTaskToExecute } from "./helpers";
2
+ import * as cleverQueue from "clever-queue";
3
+
4
+ async function run(): Promise<void> {
5
+ const engine = cleverQueue.createEngine({ autostart: false }); // create the engine and the first runner with best effort priority (0)
6
+ engine.createRunner({ priority: cleverQueue.queues.Priorities.Absolute }); // create a second runner with absolute priority (255)
7
+ const queueA = engine.createQueue({ priority: cleverQueue.queues.Priorities.Absolute, weight: 1 }); // Queue with absolute priority (255), will be served first, by the 2 runners.
8
+ const queueB = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 1 }); // Queue with standard priority (128), only by the first runner.
9
+
10
+ const tasks: cleverQueue.tasks.Task[] = [];
11
+ const promiseList: Promise<unknown>[] = [];
12
+
13
+ const tasksList: { id: string; timeout: number; queue: cleverQueue.queues.Queue }[] = [
14
+ { id: "task A1", timeout: 2500, queue: queueA },
15
+ { id: "task A2", timeout: 2500, queue: queueA },
16
+ { id: "task A3", timeout: 2500, queue: queueA },
17
+ { id: "task A4", timeout: 2500, queue: queueA },
18
+ { id: "task B1", timeout: 2500, queue: queueB },
19
+ { id: "task B2", timeout: 2500, queue: queueB },
20
+ { id: "task B3", timeout: 2500, queue: queueB },
21
+ { id: "task B4", timeout: 2500, queue: queueB },
22
+ ];
23
+
24
+ for (const taskInfo of tasksList) {
25
+ const task = engine.createTask(() => myAsyncTaskToExecute(taskInfo.id, taskInfo.timeout), { id: taskInfo.id });
26
+ tasks.push(task);
27
+ promiseList.push(taskInfo.queue.enqueue(task));
28
+ }
29
+
30
+ const anim = new animations.Animation(engine, tasks, "./documentation/" + __filename.slice(__dirname.length + 1, -3) + ".svg");
31
+
32
+ await anim.start()
33
+ engine.start();
34
+ await Promise.all(promiseList);
35
+ engine.stop();
36
+ await anim.stop();
37
+ }
38
+
39
+ (async () => {
40
+ await run();
41
+ })();
@@ -0,0 +1,45 @@
1
+ import { animations, myAsyncTaskToExecute } from "./helpers";
2
+ import * as cleverQueue from "clever-queue";
3
+
4
+ async function run(): Promise<void> {
5
+ const engine = cleverQueue.createEngine({ autostart: false });
6
+ const queueA = engine.createQueue({ priority: cleverQueue.queues.Priorities.Absolute, weight: 1 }); // Absolute priority (255), will be served first
7
+ const queueB = engine.createQueue({ priority: 100, weight: 1 }); // Random priority (between 0 and 255), will be served after queueA
8
+ const queueC = engine.createQueue({ priority: cleverQueue.queues.Priorities.BestEffort, weight: 1 }); // Best effort priority (0), will be served last
9
+
10
+ const tasks: cleverQueue.tasks.Task[] = [];
11
+ const promiseList: Promise<unknown>[] = [];
12
+
13
+ const tasksList: { id: string; timeout: number; queue: cleverQueue.queues.Queue }[] = [
14
+ { id: "task A1", timeout: 2500, queue: queueA },
15
+ { id: "task A2", timeout: 2500, queue: queueA },
16
+ { id: "task A3", timeout: 2500, queue: queueA },
17
+ { id: "task A4", timeout: 2500, queue: queueA },
18
+ { id: "task B1", timeout: 2500, queue: queueB },
19
+ { id: "task B2", timeout: 2500, queue: queueB },
20
+ { id: "task B3", timeout: 2500, queue: queueB },
21
+ { id: "task B4", timeout: 2500, queue: queueB },
22
+ { id: "task C1", timeout: 2500, queue: queueC },
23
+ { id: "task C2", timeout: 2500, queue: queueC },
24
+ { id: "task C3", timeout: 2500, queue: queueC },
25
+ { id: "task C4", timeout: 2500, queue: queueC },
26
+ ];
27
+
28
+ for (const taskInfo of tasksList) {
29
+ const task = engine.createTask(() => myAsyncTaskToExecute(taskInfo.id, taskInfo.timeout), { id: taskInfo.id });
30
+ tasks.push(task);
31
+ promiseList.push(taskInfo.queue.enqueue(task));
32
+ }
33
+
34
+ const anim = new animations.Animation(engine, tasks, "./documentation/" + __filename.slice(__dirname.length + 1, -3) + ".svg");
35
+
36
+ await anim.start()
37
+ engine.start();
38
+ await Promise.all(promiseList);
39
+ engine.stop();
40
+ await anim.stop();
41
+ }
42
+
43
+ (async () => {
44
+ await run();
45
+ })();
@@ -1,4 +1,4 @@
1
- import * as cleverQueue from "clever-queue"; // import the library - no dependancies
1
+ import * as cleverQueue from "clever-queue"; // import the library - no dependencies
2
2
 
3
3
  const engine = cleverQueue.createEngine(); // create and start (by default) engine with a single best effort runner (by default)
4
4
  const queue = engine.createQueue(); // create your first queue, with standard priority (by default) and default weight (by default)
@@ -256,8 +256,8 @@ class Animation {
256
256
  }
257
257
  }
258
258
  }
259
- if (task.status === "runned") {
260
- // task has runned
259
+ if (task.status === "completed") {
260
+ // task has completed
261
261
  x = WIDTH / 2 - TASK_WIDTH / 2;
262
262
  y = RUNNEDZONE_Y;
263
263
  }
@@ -0,0 +1,6 @@
1
+ declare module "path-expression-matcher" {
2
+ export type Expression = any;
3
+ export class Matcher {
4
+ constructor(expression: Expression);
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clever-queue",
3
- "version": "0.3.0",
4
- "description": "Queuing system for promises that handle concurring, throttling, weighting and prioritizing in a clever fashion.",
3
+ "version": "0.4.1",
4
+ "description": "Queuing system for promises that handle concurrent, throttling, weighting and prioritizing in a clever fashion.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "npx tsc -p src/ --declaration",
@@ -5,7 +5,7 @@ import * as cqQueue from "../queues";
5
5
  import * as cqRunner from "../runners";
6
6
  import * as cqTask from "../tasks";
7
7
 
8
- type Status = "unknown" | "initialiazing" | "running" | "stopping" | "destroying";
8
+ type Status = "unknown" | "initializing" | "running" | "stopping" | "destroying";
9
9
 
10
10
  const TICK_START = 42; // RANDOM ? ;-) value to avoid zero division
11
11
 
@@ -25,7 +25,7 @@ class Engine {
25
25
  readonly queues: cqQueue.Queue[] = [];
26
26
 
27
27
  constructor(opt: Options) {
28
- this.status = "initialiazing";
28
+ this.status = "initializing";
29
29
  this.options = { ...defaultOptions, ...opt };
30
30
  if (!this.options.id) this.options.id = _.Id.generate();
31
31
  this.#checkOptionsConsistancy(this.options);
@@ -111,7 +111,7 @@ class Engine {
111
111
  // Find Next Weighted Queue of this priority level to check
112
112
  const nextPriorityQueue = this.#getNextWeightedQueue(priority);
113
113
  if (nextPriorityQueue) {
114
- // update Tick (next check) according to queue related weigth
114
+ // update Tick (next check) according to queue related weight
115
115
  nextPriorityQueue.tick += this.#getSumWeightFunction(priority) / nextPriorityQueue.options.weight;
116
116
  // If queue is not empty, we've got our next Task to process
117
117
  if (nextPriorityQueue.tasks.length > 0) {
@@ -3,7 +3,7 @@ class CQError extends Error {
3
3
  if (!error) {
4
4
  error = {
5
5
  name: "undocumentedError",
6
- message: "Undocumented Error, please raise an issue to developpers",
6
+ message: "Undocumented Error, please raise an issue to developers",
7
7
  };
8
8
  }
9
9
  super(error.message);
@@ -6,7 +6,7 @@ import { Options, Statistics, ErrorsList, Priorities, Weights } from "./interfac
6
6
 
7
7
  type GetSumWeightFunction = (priority: number) => number;
8
8
 
9
- type Status = "unknown" | "initialiazing" | "running" | "stopping" | "destroying";
9
+ type Status = "unknown" | "initializing" | "running" | "stopping" | "destroying";
10
10
 
11
11
  const defaultOptions: Options = {
12
12
  autostart: true,
@@ -24,7 +24,7 @@ class Queue {
24
24
  tasks: cqTask.Task[] = [];
25
25
 
26
26
  constructor(opt: Options) {
27
- this.status = "initialiazing";
27
+ this.status = "initializing";
28
28
  this.options = this.#checkOptionsConsistancy({ ...defaultOptions, ...opt });
29
29
  if (!this.options.id) this.options.id = _.Id.generate();
30
30
  if (this.options.autostart) this.start();
@@ -32,7 +32,7 @@ class Queue {
32
32
 
33
33
  #checkOptionsConsistancy(options: Options): Options {
34
34
  if (!options) throw new _.Errors.CQError(ErrorsList.NoOptionsOnQueueInitialization);
35
- if (!(typeof options.priority === "number") || options.priority < 0 || options.priority > 255)
35
+ if (!(typeof options.priority === "number") || options.priority < Priorities.BestEffort || options.priority > Priorities.Absolute)
36
36
  throw new _.Errors.CQError(ErrorsList.BadPriorityOptionsOnQueueInitialization, options);
37
37
  if (!(typeof options.weight === "number") || options.weight < Weights.Lowest || options.weight > Weights.Highest)
38
38
  throw new _.Errors.CQError(ErrorsList.NoWeightOptionsOnQueueInitialization, options);
@@ -44,7 +44,12 @@ class Queue {
44
44
  }
45
45
 
46
46
  stop(): void {
47
+ if (this.status === "stopping") return;
47
48
  this.status = "stopping";
49
+ while (this.tasks.length > 0) {
50
+ const task = this.tasks.shift();
51
+ if (task) task.rejecter(new _.Errors.CQError(ErrorsList.QueueIsStopping));
52
+ }
48
53
  }
49
54
 
50
55
  async createTaskAndEnqueue(function_: cqTask.FunctionToExecute, options: cqTask.Options = {}): Promise<unknown> {
@@ -53,6 +58,9 @@ class Queue {
53
58
  }
54
59
 
55
60
  async enqueue(task: cqTask.Task): Promise<unknown> {
61
+ if (this.status === "stopping") throw new _.Errors.CQError(ErrorsList.QueueIsStopping);
62
+ if (this.status !== "running") throw new _.Errors.CQError(ErrorsList.QueueIsNotRunning);
63
+
56
64
  task.status = "queued";
57
65
  task.queueId = this.options.id; // store queue that handle task for future references
58
66
  return new Promise((resolve, reject) => {
@@ -1,7 +1,7 @@
1
1
  import * as _ from "../helpers";
2
2
 
3
3
  const Priorities = { BestEffort: 0, Standard: 128, Absolute: 255 };
4
- const Weights = { Lowest: 0, Default: 128, Highest: 255 };
4
+ const Weights = { Lowest: 1, Default: 128, Highest: 255 };
5
5
 
6
6
  interface Options {
7
7
  id?: string;
@@ -18,7 +18,12 @@ interface Statistics {
18
18
  tasks: number;
19
19
  }
20
20
 
21
- type ErrorListKeys = "BadPriorityOptionsOnQueueInitialization" | "NoWeightOptionsOnQueueInitialization" | "NoOptionsOnQueueInitialization";
21
+ type ErrorListKeys =
22
+ | "BadPriorityOptionsOnQueueInitialization"
23
+ | "NoWeightOptionsOnQueueInitialization"
24
+ | "NoOptionsOnQueueInitialization"
25
+ | "QueueIsStopping"
26
+ | "QueueIsNotRunning";
22
27
 
23
28
  const ErrorsList: {
24
29
  [index in ErrorListKeys]: { name: string; message: string };
@@ -30,10 +35,18 @@ const ErrorsList: {
30
35
  },
31
36
  NoWeightOptionsOnQueueInitialization: {
32
37
  name: "NoWeightOptionsOnQueueInitialization",
33
- message: "You must provide a 'weight' parameter for Queue initialization from 0 to 255, you may use CleverQueue.Weights constants",
38
+ message: "You must provide a 'weight' parameter for Queue initialization from 1 to 255, you may use CleverQueue.Weights constants",
34
39
  },
35
40
 
36
41
  NoOptionsOnQueueInitialization: { name: "NoOptionsOnQueueInitialization", message: "You must provide an options parameter to Queue" },
42
+ QueueIsStopping: {
43
+ name: "QueueIsStopping",
44
+ message: "Queue is stopping and can no longer accept new tasks",
45
+ },
46
+ QueueIsNotRunning: {
47
+ name: "QueueIsNotRunning",
48
+ message: "Queue must be running before tasks can be enqueued",
49
+ },
37
50
  };
38
51
 
39
52
  export { Options, Statistics, ErrorsList, Priorities, Weights };
@@ -6,7 +6,7 @@ import * as cqEngine from "../engine";
6
6
 
7
7
  export * from "./interfaces";
8
8
 
9
- type Status = "unknown" | "initialiazing" | "idle" | "running" | "stopping" | "destroying";
9
+ type Status = "unknown" | "initializing" | "idle" | "running" | "stopping" | "destroying";
10
10
 
11
11
  const defaultOptions: Options = {
12
12
  priority: Priorities.BestEffort,
@@ -21,7 +21,7 @@ class Runner {
21
21
  readonly #engine: cqEngine.Engine;
22
22
 
23
23
  constructor(opt: Options, engine: cqEngine.Engine) {
24
- this.status = "initialiazing";
24
+ this.status = "initializing";
25
25
  this.options = this.#checkOptionsConsistancy({ ...defaultOptions, ...opt });
26
26
  if (!this.options.id) this.options.id = _.Id.generate();
27
27
  this.#engine = engine; // Store parent engine for later callbacks
@@ -3,7 +3,7 @@
3
3
  import * as _ from "../helpers";
4
4
  import { Options, Statistics, ErrorsList, FunctionToExecute } from "./interfaces";
5
5
 
6
- type Status = "unknown" | "initialiazing" | "queued" | "running" | "runned" | "exception" | "destroying";
6
+ type Status = "unknown" | "initializing" | "queued" | "running" | "completed" | "exception" | "destroying";
7
7
 
8
8
  const defaultOptions: Options = {
9
9
  logFunction: undefined,
@@ -33,7 +33,7 @@ class Task {
33
33
  }
34
34
 
35
35
  constructor(function_: FunctionToExecute, opt: Options) {
36
- this.status = "initialiazing";
36
+ this.status = "initializing";
37
37
  this.options = this.#checkOptionsConsistancy({ ...defaultOptions, ...opt });
38
38
  if (!this.options.id) this.options.id = _.Id.generate();
39
39
  if (typeof function_ !== "function") throw new _.Errors.CQError(ErrorsList.FunctionIsNotAFunction);
@@ -46,7 +46,7 @@ class Task {
46
46
  this.status = "running";
47
47
  try {
48
48
  this.result = await this.#functionToExecute();
49
- this.status = "runned";
49
+ this.status = "completed";
50
50
  this.resolver(this.result);
51
51
  } catch (error) {
52
52
  this.status = "exception";
@@ -0,0 +1,124 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+
4
+ import * as cleverQueue from "../../dist/index.js";
5
+
6
+ function createTrackedTask(engine, label) {
7
+ return engine.createTask(() => label, { id: label });
8
+ }
9
+
10
+ async function dequeueLabels(engine, count, priority = cleverQueue.queues.Priorities.BestEffort) {
11
+ const labels = [];
12
+ for (let index = 0; index < count; index += 1) {
13
+ const task = await engine.getNextTask(priority);
14
+ assert.ok(task, `expected task ${index + 1} to be available`);
15
+ labels.push(task.options.id);
16
+ }
17
+
18
+ const finalTask = await engine.getNextTask(priority);
19
+ assert.equal(finalTask, undefined);
20
+ return labels;
21
+ }
22
+
23
+ describe("scheduler behavior", () => {
24
+ it("prefers higher-priority queues before lower-priority queues", async () => {
25
+ const engine = cleverQueue.createEngine({ autostart: false, bestEffortRunners: 1 });
26
+ const bestEffortQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.BestEffort, weight: 10 });
27
+ const standardQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 10 });
28
+ const absoluteQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Absolute, weight: 10 });
29
+
30
+ bestEffortQueue.enqueue(createTrackedTask(engine, "best-effort"));
31
+ standardQueue.enqueue(createTrackedTask(engine, "standard"));
32
+ absoluteQueue.enqueue(createTrackedTask(engine, "absolute"));
33
+
34
+ engine.start();
35
+ const labels = await dequeueLabels(engine, 3);
36
+ assert.deepEqual(labels, ["absolute", "standard", "best-effort"]);
37
+ engine.stop();
38
+ });
39
+
40
+ it("distributes work proportionally between queues with different weights", async () => {
41
+ const engine = cleverQueue.createEngine({ autostart: false, bestEffortRunners: 1 });
42
+ const heavyQueue = engine.createQueue({ id: "heavy", priority: cleverQueue.queues.Priorities.Standard, weight: 2 });
43
+ const lightQueue = engine.createQueue({ id: "light", priority: cleverQueue.queues.Priorities.Standard, weight: 1 });
44
+
45
+ for (let index = 0; index < 4; index += 1) heavyQueue.enqueue(createTrackedTask(engine, `heavy-${index}`));
46
+ for (let index = 0; index < 2; index += 1) lightQueue.enqueue(createTrackedTask(engine, `light-${index}`));
47
+
48
+ engine.start();
49
+ const labels = await dequeueLabels(engine, 6);
50
+ assert.deepEqual(labels, ["heavy-0", "heavy-1", "light-0", "heavy-2", "heavy-3", "light-1"]);
51
+ engine.stop();
52
+ });
53
+
54
+ it("starts multiple tasks concurrently when multiple runners are available", async () => {
55
+ const engine = cleverQueue.createEngine({ bestEffortRunners: 2 });
56
+ const queue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 1 });
57
+
58
+ let started = 0;
59
+ let release;
60
+ const releasePromise = new Promise((resolve) => {
61
+ release = resolve;
62
+ });
63
+ const events = [];
64
+
65
+ const createBlockingTask = (label) =>
66
+ engine.createTask(async () => {
67
+ started += 1;
68
+ events.push(`${label}:start:${started}`);
69
+ await releasePromise;
70
+ events.push(`${label}:finish`);
71
+ return label;
72
+ }, { id: label });
73
+
74
+ const first = queue.enqueue(createBlockingTask("first"));
75
+ const second = queue.enqueue(createBlockingTask("second"));
76
+
77
+ await new Promise((resolve, reject) => {
78
+ const timeout = setTimeout(() => reject(new Error("timed out waiting for both runners to start tasks")), 250);
79
+ const poll = () => {
80
+ if (started === 2) {
81
+ clearTimeout(timeout);
82
+ resolve();
83
+ return;
84
+ }
85
+
86
+ setTimeout(poll, 5);
87
+ };
88
+
89
+ poll();
90
+ });
91
+
92
+ release();
93
+ assert.deepEqual(await Promise.all([first, second]), ["first", "second"]);
94
+ assert.deepEqual(events.slice(0, 2), ["first:start:1", "second:start:2"]);
95
+ engine.stop();
96
+ });
97
+
98
+ it("keeps priority dominance while still applying weighted fairness within a priority", async () => {
99
+ const engine = cleverQueue.createEngine({ autostart: false, bestEffortRunners: 1 });
100
+ const absoluteQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Absolute, weight: 1 });
101
+ const standardHeavyQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 2 });
102
+ const standardLightQueue = engine.createQueue({ priority: cleverQueue.queues.Priorities.Standard, weight: 1 });
103
+
104
+ absoluteQueue.enqueue(createTrackedTask(engine, "absolute-0"));
105
+ absoluteQueue.enqueue(createTrackedTask(engine, "absolute-1"));
106
+ for (let index = 0; index < 4; index += 1) standardHeavyQueue.enqueue(createTrackedTask(engine, `standard-heavy-${index}`));
107
+ for (let index = 0; index < 2; index += 1) standardLightQueue.enqueue(createTrackedTask(engine, `standard-light-${index}`));
108
+
109
+ engine.start();
110
+ const labels = await dequeueLabels(engine, 8);
111
+
112
+ assert.deepEqual(labels, [
113
+ "absolute-0",
114
+ "absolute-1",
115
+ "standard-heavy-0",
116
+ "standard-heavy-1",
117
+ "standard-light-0",
118
+ "standard-heavy-2",
119
+ "standard-heavy-3",
120
+ "standard-light-1",
121
+ ]);
122
+ engine.stop();
123
+ });
124
+ });