@cldmv/holdmytask 2.0.6 → 2.1.0
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/README.md +14 -12
- package/{index.cjs → dist/index.cjs} +11 -5
- package/dist/index.mjs +13 -0
- package/dist/main.mjs +2 -0
- package/package.json +49 -40
- package/types/src/hold-my-task.d.mts +802 -0
- package/types/src/hold-my-task.d.mts.map +1 -0
- package/types/src/index.d.mts +27 -0
- package/types/src/index.d.mts.map +1 -0
- package/types/src/main.d.mts +3 -0
- package/types/src/main.d.mts.map +1 -0
- package/types/src/utils.d.mts +74 -0
- package/types/src/utils.d.mts.map +1 -0
- package/dist/hold-my-task.mjs +0 -3031
- package/dist/utils.mjs +0 -122
- package/index.mjs +0 -76
- package/types/index.d.mts +0 -48
- package/types/index.d.mts.map +0 -1
package/dist/utils.mjs
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @Project: @cldmv/holdmytask
|
|
4
|
-
* @Filename: /src/utils.mjs
|
|
5
|
-
* @Date: 2025-11-08T17:43:09-08:00 (1762652589)
|
|
6
|
-
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
-
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
-
* -----
|
|
9
|
-
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-10-02T12:20:29-07:00 (1790968829)
|
|
11
|
-
* -----
|
|
12
|
-
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A min-heap implementation with custom comparison function.
|
|
18
|
-
* Maintains the heap property where parent nodes are smaller than their children.
|
|
19
|
-
*/
|
|
20
|
-
export class MinHeap {
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new MinHeap with a custom comparison function.
|
|
23
|
-
* @param {Function} compare - Comparison function that returns negative if a < b, positive if a > b, 0 if equal
|
|
24
|
-
* @example
|
|
25
|
-
* // Priority queue (higher priority = smaller value)
|
|
26
|
-
* const heap = new MinHeap((a, b) => a.priority - b.priority);
|
|
27
|
-
*/
|
|
28
|
-
constructor(compare) {
|
|
29
|
-
this.heap = [];
|
|
30
|
-
this.compare = compare;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Adds an item to the heap, maintaining heap property.
|
|
35
|
-
* @param {*} item - The item to add to the heap
|
|
36
|
-
* @returns {void}
|
|
37
|
-
* @example
|
|
38
|
-
* heap.push({ value: 5, priority: 1 });
|
|
39
|
-
*/
|
|
40
|
-
push(item) {
|
|
41
|
-
this.heap.push(item);
|
|
42
|
-
this.bubbleUp(this.heap.length - 1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Removes and returns the minimum item from the heap.
|
|
47
|
-
* @returns {*|undefined} The minimum item, or undefined if heap is empty
|
|
48
|
-
* @example
|
|
49
|
-
* const min = heap.pop(); // Returns item with smallest comparison value
|
|
50
|
-
*/
|
|
51
|
-
pop() {
|
|
52
|
-
if (this.heap.length === 0) return undefined;
|
|
53
|
-
const root = this.heap[0];
|
|
54
|
-
const last = this.heap.pop();
|
|
55
|
-
if (this.heap.length > 0) {
|
|
56
|
-
this.heap[0] = last;
|
|
57
|
-
this.sinkDown(0);
|
|
58
|
-
}
|
|
59
|
-
return root;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Returns the minimum item without removing it from the heap.
|
|
64
|
-
* @returns {*|undefined} The minimum item, or undefined if heap is empty
|
|
65
|
-
* @example
|
|
66
|
-
* const min = heap.peek(); // Look at minimum without removing
|
|
67
|
-
*/
|
|
68
|
-
peek() {
|
|
69
|
-
return this.heap[0];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Returns the number of items in the heap.
|
|
74
|
-
* @returns {number} The size of the heap
|
|
75
|
-
* @example
|
|
76
|
-
* const count = heap.size(); // 5
|
|
77
|
-
*/
|
|
78
|
-
size() {
|
|
79
|
-
return this.heap.length;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Moves an item up the heap to maintain heap property after insertion.
|
|
84
|
-
* @param {number} index - Index of the item to bubble up
|
|
85
|
-
* @returns {void}
|
|
86
|
-
* @private
|
|
87
|
-
*/
|
|
88
|
-
bubbleUp(index) {
|
|
89
|
-
while (index > 0) {
|
|
90
|
-
const parentIndex = Math.floor((index - 1) / 2);
|
|
91
|
-
if (this.compare(this.heap[index], this.heap[parentIndex]) >= 0) break;
|
|
92
|
-
[this.heap[index], this.heap[parentIndex]] = [this.heap[parentIndex], this.heap[index]];
|
|
93
|
-
index = parentIndex;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Moves an item down the heap to maintain heap property after removal.
|
|
99
|
-
* @param {number} index - Index of the item to sink down
|
|
100
|
-
* @returns {void}
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
sinkDown(index) {
|
|
104
|
-
const length = this.heap.length;
|
|
105
|
-
while (true) {
|
|
106
|
-
let left = 2 * index + 1;
|
|
107
|
-
let right = 2 * index + 2;
|
|
108
|
-
let smallest = index;
|
|
109
|
-
|
|
110
|
-
if (left < length && this.compare(this.heap[left], this.heap[smallest]) < 0) {
|
|
111
|
-
smallest = left;
|
|
112
|
-
}
|
|
113
|
-
if (right < length && this.compare(this.heap[right], this.heap[smallest]) < 0) {
|
|
114
|
-
smallest = right;
|
|
115
|
-
}
|
|
116
|
-
if (smallest === index) break;
|
|
117
|
-
|
|
118
|
-
[this.heap[index], this.heap[smallest]] = [this.heap[smallest], this.heap[index]];
|
|
119
|
-
index = smallest;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
package/index.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @Project: @cldmv/holdmytask
|
|
4
|
-
* @Filename: /index.mjs
|
|
5
|
-
* @Date: 2025-11-08T14:04:10-08:00 (1762639450)
|
|
6
|
-
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
-
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
-
* -----
|
|
9
|
-
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-10-02T12:20:28-07:00 (1790968828)
|
|
11
|
-
* -----
|
|
12
|
-
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
// Development environment check. NOTE: the static `import` of the core below is
|
|
17
|
-
// hoisted and evaluated before this IIFE body runs, so devcheck does NOT run before
|
|
18
|
-
// the core loads - it's a best-effort, fire-and-forget dev-time warning. (Running it
|
|
19
|
-
// strictly first would require a dynamic import + top-level await, which breaks the
|
|
20
|
-
// index.cjs bridge's synchronous `require` of this module - see PR #11 discussion.)
|
|
21
|
-
(async () => {
|
|
22
|
-
try {
|
|
23
|
-
await import("./devcheck.mjs");
|
|
24
|
-
} catch {
|
|
25
|
-
// ignore
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
|
|
29
|
-
import { HoldMyTask } from "@cldmv/holdmytask/main";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a HoldMyTask instance for task queue management
|
|
33
|
-
* @param {object} [options={}] - Configuration options
|
|
34
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
35
|
-
*/
|
|
36
|
-
export async function createHoldMyTask(options = {}) {
|
|
37
|
-
return new HoldMyTask(options);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Create a task queue instance
|
|
42
|
-
* @param {object} [options={}] - Configuration options
|
|
43
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
44
|
-
*/
|
|
45
|
-
export async function createQueue(options = {}) {
|
|
46
|
-
return new HoldMyTask(options);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create a task manager instance
|
|
51
|
-
* @param {object} [options={}] - Configuration options
|
|
52
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
53
|
-
*/
|
|
54
|
-
export async function createTaskManager(options = {}) {
|
|
55
|
-
return new HoldMyTask(options);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Create a task processor instance
|
|
60
|
-
* @param {object} [options={}] - Configuration options
|
|
61
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
62
|
-
*/
|
|
63
|
-
export async function createTaskProcessor(options = {}) {
|
|
64
|
-
return new HoldMyTask(options);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// HoldMyTask and its constructor aliases are the real class (see issue #3) - `new
|
|
68
|
-
// HoldMyTask()`, `new QueueManager()`, etc. all construct the same underlying type.
|
|
69
|
-
export { HoldMyTask };
|
|
70
|
-
export default HoldMyTask;
|
|
71
|
-
export { HoldMyTask as queue };
|
|
72
|
-
export { HoldMyTask as Queue };
|
|
73
|
-
export { HoldMyTask as TaskManager };
|
|
74
|
-
export { HoldMyTask as TaskQueue };
|
|
75
|
-
export { HoldMyTask as QueueManager };
|
|
76
|
-
export { HoldMyTask as TaskProcessor };
|
package/types/index.d.mts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @Project: @cldmv/holdmytask
|
|
4
|
-
* @Filename: /index.mjs
|
|
5
|
-
* @Date: 2025-11-08T14:04:10-08:00 (1762639450)
|
|
6
|
-
* @Author: Nate Corcoran <CLDMV>
|
|
7
|
-
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
|
-
* -----
|
|
9
|
-
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-10-02T12:20:28-07:00 (1790968828)
|
|
11
|
-
* -----
|
|
12
|
-
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
import { HoldMyTask } from "@cldmv/holdmytask/main";
|
|
16
|
-
/**
|
|
17
|
-
* Creates a HoldMyTask instance for task queue management
|
|
18
|
-
* @param {object} [options={}] - Configuration options
|
|
19
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
20
|
-
*/
|
|
21
|
-
export declare function createHoldMyTask(options?: object): Promise<HoldMyTask>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a task queue instance
|
|
24
|
-
* @param {object} [options={}] - Configuration options
|
|
25
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
26
|
-
*/
|
|
27
|
-
export declare function createQueue(options?: object): Promise<HoldMyTask>;
|
|
28
|
-
/**
|
|
29
|
-
* Create a task manager instance
|
|
30
|
-
* @param {object} [options={}] - Configuration options
|
|
31
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
32
|
-
*/
|
|
33
|
-
export declare function createTaskManager(options?: object): Promise<HoldMyTask>;
|
|
34
|
-
/**
|
|
35
|
-
* Create a task processor instance
|
|
36
|
-
* @param {object} [options={}] - Configuration options
|
|
37
|
-
* @returns {Promise<HoldMyTask>} HoldMyTask instance
|
|
38
|
-
*/
|
|
39
|
-
export declare function createTaskProcessor(options?: object): Promise<HoldMyTask>;
|
|
40
|
-
export { HoldMyTask };
|
|
41
|
-
export default HoldMyTask;
|
|
42
|
-
export { HoldMyTask as queue };
|
|
43
|
-
export { HoldMyTask as Queue };
|
|
44
|
-
export { HoldMyTask as TaskManager };
|
|
45
|
-
export { HoldMyTask as TaskQueue };
|
|
46
|
-
export { HoldMyTask as QueueManager };
|
|
47
|
-
export { HoldMyTask as TaskProcessor };
|
|
48
|
-
//# sourceMappingURL=index.d.mts.map
|
package/types/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,AAH3C,CACA,EADQ,MAGwC,GAFtC,OAAO,CAAC,UAAU,CAAC,CAI/B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,AAHtC,CACA,EADQ,MAGmC,GAFjC,OAAO,CAAC,UAAU,CAAC,CAI/B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,AAH5C,CACA,EADQ,MAGyC,GAFvC,OAAO,CAAC,UAAU,CAAC,CAI/B;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,AAH9C,CACA,EADQ,MAG2C,GAFzC,OAAO,CAAC,UAAU,CAAC,CAI/B;AAID,OAAO,EAAE,UAAU,EAAE,CAAC;eACP,UAAU;AACzB,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,CAAC;AAC/B,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,CAAC;AAC/B,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,CAAC;AACrC,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC;AACnC,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,CAAC;AACtC,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,CAAC"}
|