@stonyx/cron 0.2.1-alpha.0 → 0.2.1-alpha.10

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.
package/src/min-heap.js DELETED
@@ -1,73 +0,0 @@
1
- export default class MinHeap {
2
- constructor() {
3
- this.items = [];
4
- }
5
-
6
- push(job) {
7
- this.items.push(job);
8
- this.bubbleUp();
9
- }
10
-
11
- pop() {
12
- if (this.items.length === 1) return this.items.pop();
13
- const top = this.items[0];
14
- this.items[0] = this.items.pop();
15
- this.bubbleDown();
16
- return top;
17
- }
18
-
19
- peek() {
20
- return this.items[0];
21
- }
22
-
23
- bubbleUp() {
24
- let idx = this.items.length - 1;
25
- while (idx > 0) {
26
- const parentIdx = Math.floor((idx - 1) / 2);
27
- if (this.items[idx].nextTrigger >= this.items[parentIdx].nextTrigger) break;
28
- [this.items[idx], this.items[parentIdx]] = [this.items[parentIdx], this.items[idx]];
29
- idx = parentIdx;
30
- }
31
- }
32
-
33
- bubbleDown() {
34
- let idx = 0;
35
- const length = this.items.length;
36
-
37
- while (true) {
38
- let leftIdx = 2 * idx + 1;
39
- let rightIdx = 2 * idx + 2;
40
- let swapIdx = null;
41
-
42
- if (leftIdx < length && this.items[leftIdx].nextTrigger < this.items[idx].nextTrigger) {
43
- swapIdx = leftIdx;
44
- }
45
- if (
46
- rightIdx < length &&
47
- this.items[rightIdx].nextTrigger < (
48
- swapIdx === null ? this.items[idx].nextTrigger : this.items[leftIdx].nextTrigger
49
- )
50
- ) {
51
- swapIdx = rightIdx;
52
- }
53
- if (swapIdx === null) break;
54
- [this.items[idx], this.items[swapIdx]] = [this.items[swapIdx], this.items[idx]];
55
- idx = swapIdx;
56
- }
57
- }
58
-
59
- remove(job) {
60
- const idx = this.items.indexOf(job);
61
- if (idx === -1) return;
62
- const end = this.items.pop();
63
- if (idx < this.items.length) {
64
- this.items[idx] = end;
65
- this.bubbleUp();
66
- this.bubbleDown();
67
- }
68
- }
69
-
70
- isEmpty() {
71
- return this.items.length === 0;
72
- }
73
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * commonJS Bootstrap loading - Stonyx must be loaded first, prior to the rest of the application
3
- */
4
- const { default:Stonyx } = require('stonyx');
5
- const { default:config } = require('./config/environment.js');
6
-
7
- new Stonyx(config, __dirname);
8
-
9
- module.exports = Stonyx;