@cldmv/holdmytask 2.0.4 → 2.0.6

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 CHANGED
@@ -1,31 +1,39 @@
1
1
  # @cldmv/holdmytask
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837)](https://www.npmjs.com/package/@cldmv/holdmytask)
4
- [![npm downloads](https://img.shields.io/npm/dm/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837)](https://www.npmjs.com/package/@cldmv/holdmytask)
5
- [![GitHub downloads](https://img.shields.io/github/downloads/CLDMV/holdmytask/total?style=for-the-badge&logo=github&logoColor=white&labelColor=181717)](https://github.com/CLDMV/holdmytask/releases)
6
- [![Last commit](https://img.shields.io/github/last-commit/CLDMV/holdmytask?style=for-the-badge&logo=github&logoColor=white&labelColor=181717)](https://github.com/CLDMV/holdmytask/commits)
7
- [![npm last update](https://img.shields.io/npm/last-update/%40cldmv%2Fholdmytask?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837)](https://www.npmjs.com/package/@cldmv/holdmytask)
3
+ **@cldmv/holdmytask** is a tiny, dependency-free task queue for Node.js that executes tasks with priority ordering, concurrency control, and completion delays. It is built for asynchronous workflows with real timing requirements: rate-limited APIs, device control, UI refreshes, and anything else where _when_ a task runs matters as much as _whether_ it runs.
8
4
 
9
- [![Contributors](https://img.shields.io/github/contributors/CLDMV/holdmytask.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717)](https://github.com/CLDMV/holdmytask/graphs/contributors) [![Sponsor shinrai](https://img.shields.io/github/sponsors/shinrai?style=for-the-badge&logo=githubsponsors&logoColor=white&labelColor=EA4AAA&label=Sponsor)](https://github.com/sponsors/shinrai)
5
+ Every task can carry a priority, a scheduled start time, a timeout, an `AbortSignal`, and metadata. Per-priority concurrency limits and pre/post delays shape throughput, urgent work can bypass an active delay, and tasks that share a coalescing key collapse into a single execution whose result resolves every caller. Smart scheduling sets precise timers for the next ready task instead of polling.
10
6
 
11
- A tiny, dependency-free task queue for Node.js that executes tasks with priority ordering, concurrency control, and completion delays. Perfect for managing asynchronous workflows with sophisticated timing requirements.
7
+ Use it with callbacks or promises, from ESM or CommonJS, with full TypeScript definitions included.
8
+
9
+ > _A tiny task queue that waits until your task is ready._
10
+
11
+ [![npm version]][npm_version_url] [![npm downloads]][npm_downloads_url] [![GitHub downloads]][github_downloads_url] [![Last commit]][last_commit_url] [![npm last update]][npm_last_update_url] [![coverage]][coverage_url]
12
+
13
+ [![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
14
+
15
+ ---
12
16
 
13
17
  ## ✨ What's New
14
18
 
15
- ### Latest: v2.0.4 (October 2026)
19
+ ### Latest: v2.0.6 (October 2026)
16
20
 
17
- - **Clearer `require()` failure on older Node.js** — The CommonJS entry now throws an `ERR_REQUIRE_ESM` error that names the supported Node.js versions (`^20.19.0` or `>=22.12.0`) and points to `import()`, instead of a bare error on versions without `require(esm)`. Behavior on supported versions is unchanged.
18
- - **Security patch for development tooling** — Updates `brace-expansion` to 5.0.12, fixing [GHSA-q2hr-2g5m-vwhr](https://github.com/advisories/GHSA-q2hr-2g5m-vwhr), a quadratic-time denial of service in a development-only dependency pulled in by `minimatch`. `@eslint/css` moves to 2.0.0 and `prettier` to 3.9.9.
19
- - [View full v2.0.4 Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.4.md)
21
+ - **Development dependencies only** — `eslint` 10.12.0, `globals` 17.13.0, `@cldmv/vitest-runner` 1.5.3 and `@types/node` 26.6.4, all lockfile-only moves. The published package and its supported Node.js range (`>=18.12`) are unchanged (#64, #65, #66).
22
+ - **Test runner now declares Node.js 22.12 or newer** — `@cldmv/vitest-runner` 1.5.3 raises its minimum from 20.19 and brings `chalk` 6; the development toolchain already needed 22.12.
23
+ - [View full v2.0.6 Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.6.md)
20
24
 
21
25
  ### Recent Releases
22
26
 
27
+ - **v2.0.5** (October 2026) — Task-level `postDelay` / `startDelay` honored, failing callback tasks no longer crash the process, and header tooling on fix-headers 2.2.0 ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.5.md))
28
+ - **v2.0.4** (October 2026) — Clearer `require()` error on Node.js without `require(esm)`; `brace-expansion` security patch in development tooling ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.4.md))
23
29
  - **v2.0.3** (October 2026) — Development toolchain moves to vitest 5; bundle-size and v4 workflow updates; verbatim Apache-2.0 license text ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.3.md))
24
30
  - **v2.0.2** (September 2026) — Development dependency update (`@humanfs/node`); no other changes ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.2.md))
25
- - **v2.0.1** (September 2026) — Fix: a task's timeout timer is now cleared when the task fails or is cancelled ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.1.md))
26
- - **v2.0.0** (August 2026) — `HoldMyTask` and its aliases are the real class again (breaking for code adapted to v1.6.1's factories); scheduler deadlock fix; `holdmytask-dev` export condition ([Changelog](https://github.com/CLDMV/holdmytask/blob/master/docs/changelog/v2/v2.0.0.md))
27
31
 
28
- ## ✨ Features
32
+ 📚 **For complete version history and detailed release notes, see the [docs/changelog/](https://github.com/CLDMV/holdmytask/tree/master/docs/changelog/) folder.**
33
+
34
+ ---
35
+
36
+ ## 🚀 Key Features
29
37
 
30
38
  - **Smart scheduling** - Dynamic timeout-based scheduling for optimal performance
31
39
  - **Task coalescing** - Intelligent merging of similar tasks for efficiency
@@ -40,13 +48,72 @@ A tiny, dependency-free task queue for Node.js that executes tasks with priority
40
48
  - **TypeScript ready** - Full type definitions included
41
49
  - **Zero dependencies** - Lightweight and fast
42
50
 
51
+ ---
52
+
43
53
  ## 📦 Installation
44
54
 
55
+ ### Requirements
56
+
57
+ - **Node.js v18.12.0 or higher** for ESM (`import`), as declared in the package's `engines` field
58
+ - **CommonJS `require()`** needs Node.js `^20.19.0` or `>=22.12.0`. The CommonJS entry is a thin wrapper that loads the ESM build through Node's synchronous `require(esm)`. On older Node.js versions `require("@cldmv/holdmytask")` throws an `ERR_REQUIRE_ESM` error that names the supported versions; load the package with `import()` instead.
59
+
60
+ ### Install
61
+
45
62
  ```bash
46
63
  npm install @cldmv/holdmytask
47
64
  ```
48
65
 
49
- ## � Import Options
66
+ ---
67
+
68
+ ## 🚀 Quick Start
69
+
70
+ ```javascript
71
+ import { HoldMyTask } from "@cldmv/holdmytask";
72
+
73
+ const queue = new HoldMyTask({
74
+ concurrency: 2,
75
+ priorities: {
76
+ 1: { postDelay: 100 }, // 100ms delay after priority 1 tasks
77
+ 2: { postDelay: 200 } // 200ms delay after priority 2 tasks
78
+ },
79
+ coalescing: {
80
+ defaults: {
81
+ windowDuration: 200, // Group similar tasks within 200ms
82
+ maxDelay: 1000 // Force execution after 1000ms max
83
+ }
84
+ }
85
+ });
86
+
87
+ // Enqueue a task
88
+ queue.enqueue(
89
+ async (signal) => {
90
+ // Your task logic here
91
+ return "task result";
92
+ },
93
+ (error, result) => {
94
+ if (error) {
95
+ console.error("Task failed:", error);
96
+ } else {
97
+ console.log("Task completed:", result);
98
+ }
99
+ },
100
+ { priority: 1, timeout: 5000 }
101
+ );
102
+
103
+ // Coalescing example - multiple similar tasks become one
104
+ const results = await Promise.all([
105
+ queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" }),
106
+ queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" }),
107
+ queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" })
108
+ ]);
109
+ // Only one updateUI() call executes, all three promises resolve with the same result
110
+ ```
111
+
112
+ CommonJS works the same way: `const { HoldMyTask } = require("@cldmv/holdmytask")` (see [Requirements](#requirements) for the Node.js versions that support `require()`).
113
+
114
+ ---
115
+
116
+ ## 📥 Import Options
50
117
 
51
118
  The library provides flexible import options for different use cases:
52
119
 
@@ -62,13 +129,10 @@ import HoldMyTask from "@cldmv/holdmytask";
62
129
  // Import everything
63
130
  import * as HoldMyTaskLib from "@cldmv/holdmytask";
64
131
  // Uses optimized distribution files
65
- ```
66
-
67
- ### Development Source Access
68
132
 
69
- ```javascript
70
- import { HoldMyTask } from "@cldmv/holdmytask/main";
71
- // Conditional: uses source files in development, dist files in production
133
+ // CommonJS (Node.js ^20.19.0 or >=22.12.0)
134
+ const HoldMyTask = require("@cldmv/holdmytask"); // the class itself
135
+ const { HoldMyTask: Named } = require("@cldmv/holdmytask"); // or by name
72
136
  ```
73
137
 
74
138
  ### Common Queue System Aliases
@@ -89,54 +153,27 @@ import {
89
153
  // All aliases are functionally identical
90
154
  const myQueue = new queue({ concurrency: 5 });
91
155
  const stdQueue = new Queue({ concurrency: 5 });
92
- const manager = new TaskManager({ priorities: { high: { delay: 100 } } });
156
+ const manager = new TaskManager({ priorities: { 1: { postDelay: 100 } } });
93
157
  ```
94
158
 
95
- ### Direct Source Import (Development Only)
159
+ The ESM entry also exports async factory helpers that resolve to a new instance: `createHoldMyTask(options)`, `createQueue(options)`, `createTaskManager(options)`, and `createTaskProcessor(options)`.
160
+
161
+ ### Development Source Access
96
162
 
97
163
  ```javascript
98
- import { HoldMyTask } from "@cldmv/holdmytask/src";
99
- // Always uses source files - bypasses devcheck
164
+ import { HoldMyTask } from "@cldmv/holdmytask/main";
165
+ // Resolves to dist files by default; resolves to src/ when Node.js runs with the holdmytask-dev condition
100
166
  ```
101
167
 
102
- **Note:** The main import automatically runs environment checks in development mode to ensure proper configuration.
168
+ To run against the unbuilt source (from a checkout of this repository), start Node.js with the `holdmytask-dev` export condition:
103
169
 
104
- ## 🚀 Quick Start
105
-
106
- ```javascript
107
- import { HoldMyTask } from "@cldmv/holdmytask";
108
-
109
- const queue = new HoldMyTask({
110
- concurrency: 2,
111
- delays: { 1: 100, 2: 200 }, // 100ms delay after priority 1 tasks, 200ms after priority 2
112
- coalescingWindowDuration: 200, // Group similar tasks within 200ms
113
- coalescingMaxDelay: 1000 // Force execution after 1000ms max
114
- });
170
+ ```bash
171
+ node --conditions=holdmytask-dev your-script.mjs
172
+ ```
115
173
 
116
- // Enqueue a task
117
- queue.enqueue(
118
- async (signal) => {
119
- // Your task logic here
120
- return "task result";
121
- },
122
- (error, result) => {
123
- if (error) {
124
- console.error("Task failed:", error);
125
- } else {
126
- console.log("Task completed:", result);
127
- }
128
- },
129
- { priority: 1, timeout: 5000 }
130
- );
174
+ **Note:** In a checkout of this repository, the root import runs a best-effort development environment check (`devcheck.mjs`) that exits with setup instructions when `src/` is present but the `holdmytask-dev` condition is not set. The check is skipped when the package is installed as a dependency and in CI.
131
175
 
132
- // Coalescing example - multiple similar tasks become one
133
- const results = await Promise.all([
134
- queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" }),
135
- queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" }),
136
- queue.enqueue(async () => updateUI(), { coalescingKey: "ui.update" })
137
- ]);
138
- // Only one updateUI() call executes, all three promises resolve with the same result
139
- ```
176
+ ---
140
177
 
141
178
  ## 🔄 Promise API
142
179
 
@@ -180,6 +217,8 @@ queue.enqueue(task1, callback, options);
180
217
  const result = await queue.enqueue(task2, options);
181
218
  ```
182
219
 
220
+ ---
221
+
183
222
  ## 🏗️ Async Constructor Pattern
184
223
 
185
224
  HoldMyTask works excellently with async constructor patterns for classes that need initialization:
@@ -241,6 +280,8 @@ This pattern is particularly useful for:
241
280
  - **Resource acquisition**: Set up required resources in a controlled manner
242
281
  - **Dependency injection**: Initialize dependencies in the correct order
243
282
 
283
+ ---
284
+
244
285
  ## 📚 API Reference
245
286
 
246
287
  ### Constructor
@@ -251,25 +292,22 @@ const queue = new HoldMyTask(options?)
251
292
 
252
293
  ### Async Initialization Pattern
253
294
 
254
- For async initialization that allows event listeners to be attached before any initialization events can fire, use `sync: false`:
295
+ With `sync: false`, the constructor returns a Promise that resolves to the instance once initialization has run on the next turn of the event loop. The returned value is a plain Promise, so attach listeners to the resolved instance:
255
296
 
256
297
  ```javascript
257
298
  // Create instance with async initialization
258
- const queuePromise = new HoldMyTask({
299
+ const queue = await new HoldMyTask({
259
300
  concurrency: 5,
260
301
  maxQueue: 100,
261
302
  sync: false // Enable async initialization
262
303
  });
263
304
 
264
- // Attach event listeners before initialization completes
265
- queuePromise.on("error", (err) => console.error("Queue error:", err));
266
- queuePromise.on("warning", (warning) => console.warn("Warning:", warning.message));
267
-
268
- // Wait for initialization to complete
269
- const queue = await queuePromise;
305
+ // Initialization warnings are emitted asynchronously, so listeners attached here still receive them
306
+ queue.on("error", (err) => console.error("Queue error:", err));
307
+ queue.on("warning", (warning) => console.warn("Warning:", warning.message));
270
308
  ```
271
309
 
272
- This pattern is particularly useful when you need to handle initialization errors or warnings through event listeners rather than try/catch blocks.
310
+ Initialization warnings (such as [deprecation warnings](#warning-events)) are emitted on `setImmediate` in both modes, so a listener attached right after a synchronous `new HoldMyTask(...)` receives them as well.
273
311
 
274
312
  **Options:**
275
313
 
@@ -279,26 +317,25 @@ This pattern is particularly useful when you need to handle initialization error
279
317
  - `autoStart` (boolean, default: true) - Whether to start processing immediately
280
318
  - `defaultPriority` (number, default: 0) - Default task priority
281
319
  - `maxQueue` (number, default: Infinity) - Maximum queued tasks. Use `-1` for unlimited queue capacity (equivalent to `Infinity`)
282
- - `delays` (object, default: {}) - **DEPRECATED:** Priority-to-delay mapping for completion delays (use `priorities` instead)
283
- - `priorities` (object, default: {}) - Priority-specific configuration: `{ [priority]: { concurrency, postDelay, startDelay } }`
320
+ - `priorities` (object, default: {}) - Priority-specific configuration: `{ [priority]: { concurrency, postDelay, startDelay } }`. Keys must be integers; any other key emits a `warning` event with `type: "invalid-priority"` (and is ignored when it isn't numeric at all)
284
321
  - `concurrency` (number) - Maximum concurrent tasks for this priority (defaults to global concurrency limit)
285
- - `postDelay` (number) - Delay after task completion before next task of same priority
322
+ - `postDelay` (number) - Delay after a task of this priority completes before the next task can start (the delay applies queue-wide; see [Priority Delays](#priority-delays---advanced-timing-control))
286
323
  - `startDelay` (number) - Delay before task execution (pre-execution delay)
287
324
  - `coalescing` (object) - Enhanced coalescing configuration
288
325
  - `defaults` (object) - Default settings for all coalescing keys
289
326
  - `windowDuration` (number, default: 200) - Window duration in milliseconds
290
327
  - `maxDelay` (number, default: 1000) - Maximum delay before forcing execution
291
- - `delay` (number) - Default completion delay for coalescing tasks
292
- - `start` (number) - Default start delay for coalescing tasks
293
- - `resolveAllPromises` (boolean, default: true) - Whether all promises resolve with result
328
+ - `postDelay` (number) - Default completion delay for coalescing tasks
329
+ - `startDelay` (number) - Default start delay for coalescing tasks
330
+ - `resolveAllPromises` (boolean, default: true) - Whether every task in a coalescing group resolves with the result; when `false`, only the newest task resolves and the others are rejected with `Task was coalesced with a newer task`
294
331
  - `multipleCallbacks` (boolean, default: false) - Whether to call multiple callbacks
295
- - `keys` (object) - Per-key configuration overrides: `{ [key]: { windowDuration, maxDelay, delay, start, ... } }`
296
- - `coalescingWindowDuration` (number, default: 200) - **DEPRECATED:** Use `coalescing.defaults.windowDuration`
297
- - `coalescingMaxDelay` (number, default: 1000) - **DEPRECATED:** Use `coalescing.defaults.maxDelay`
298
- - `coalescingResolveAllPromises` (boolean, default: true) - **DEPRECATED:** Use `coalescing.defaults.resolveAllPromises`
299
- - `onError` (function) - Global error handler
332
+ - `keys` (object) - Per-key configuration overrides: `{ [key]: { windowDuration, maxDelay, postDelay, startDelay, ... } }`
333
+ - `healingInterval` (number, default: 5000) - Self-healing check interval in milliseconds (smart scheduling only)
334
+ - `sync` (boolean, default: true) - Set to `false` for [async initialization](#async-initialization-pattern); the constructor then returns a Promise that resolves to the instance
300
335
  - `now` (function) - Injectable clock for testing
301
336
 
337
+ Deprecated option names are still accepted and converted for you, but each one emits a `warning` event; see [Deprecated Options](#deprecated-options) for the mapping.
338
+
302
339
  ### Methods
303
340
 
304
341
  #### `enqueue(task, callback?, options?)`
@@ -314,12 +351,12 @@ Adds a task to the queue.
314
351
  **Task Options:**
315
352
 
316
353
  - `priority` (number) - Task priority (higher = more important)
317
- - `delay` (number) - Override completion delay for this task (use -1 to bypass delays)
354
+ - `postDelay` (number) - Override completion delay for this task (use -1 to bypass delays). `delay` is a deprecated alias that emits a `warning` event once per queue
318
355
  - `bypassDelay` (boolean) - If true, skip any active delay period and start immediately
319
356
  - `timeout` (number) - Timeout in milliseconds
320
357
  - `signal` (AbortSignal) - External abort signal
321
358
  - `timestamp` (number) - Absolute execution timestamp
322
- - `start` (number) - Milliseconds from now when the task should be ready to run (convenience for timestamp calculation)
359
+ - `startDelay` (number) - Milliseconds from now when the task should be ready to run (convenience for timestamp calculation). `start` is a deprecated alias that emits a `warning` event once per queue
323
360
  - `coalescingKey` (string) - Tasks with the same coalescing key can be merged for efficiency
324
361
  - `mustRunBy` (number) - Absolute timestamp by which the task must execute (overrides coalescing delays)
325
362
  - `metadata` (any) - Custom metadata attached to the task. Individual metadata is always directly accessible via the returned task handle
@@ -439,10 +476,10 @@ queue.enqueue(task2, { id: "duplicate" }); // throws: Task ID "duplicate" alread
439
476
 
440
477
  - `configurePriority(priority, config)` - Configure or update priority-specific settings
441
478
  - `priority` (string|number) - Priority level to configure
442
- - `config` (object) - Configuration: `{ delay?, maxDelay?, start? }`
479
+ - `config` (object) - Configuration: `{ postDelay?, startDelay? }`
443
480
  - `configureCoalescingKey(key, config)` - Configure or update coalescing key settings
444
481
  - `key` (string) - Coalescing key to configure
445
- - `config` (object) - Configuration: `{ windowDuration?, maxDelay?, delay?, start?, multipleCallbacks?, resolveAllPromises? }`
482
+ - `config` (object) - Configuration: `{ windowDuration?, maxDelay?, postDelay?, startDelay?, multipleCallbacks?, resolveAllPromises? }`
446
483
  - `getPriorityConfig(priority, taskOptions?)` - Get effective configuration for a specific priority
447
484
  - `getPriorityConfigurations()` - Get all configured priorities and their settings
448
485
  - `getCoalescingConfig(coalescingKey, taskOptions?)` - Get effective configuration for a specific coalescing key
@@ -575,7 +612,7 @@ const queue = new HoldMyTask({ concurrency: 2 });
575
612
 
576
613
  // Add some tasks
577
614
  queue.enqueue(async () => "task1");
578
- queue.enqueue(async () => "task2", { priority: 2, start: 5000 });
615
+ queue.enqueue(async () => "task2", { priority: 2, startDelay: 5000 });
579
616
 
580
617
  // Check initial state
581
618
  console.log("Initial state:");
@@ -617,28 +654,66 @@ queue.on("warning", (warning) => {
617
654
  });
618
655
  ```
619
656
 
620
- ### Deprecation Warning Events
657
+ When a callback-style task fails, times out, or is aborted, the task's callback receives the failure. The queue also emits an `error` event with the task (its `error` and `status` properties describe the failure), but only when an `error` listener is attached, so a listener is optional. Promise-style tasks report task failures only through the rejected promise.
658
+
659
+ The callback's first argument is an error payload rather than the raw error: `{ type: "timeout", message }`, `{ type: "canceled", message: "Task was aborted" }`, or `{ type: "error", error }`.
660
+
661
+ ### Warning Events
662
+
663
+ HoldMyTask reports configuration problems through `warning` events instead of throwing. The events are emitted asynchronously (on `setImmediate`), so a listener attached right after the constructor returns still receives them. There are two types.
621
664
 
622
- When deprecated configuration options are used, HoldMyTask emits `warning` events to help with migration:
665
+ **Deprecations** (`type: "deprecation"`): when deprecated options are used, HoldMyTask converts them to the current names and emits one warning per deprecated option:
666
+
667
+ - `type` - `"deprecation"`
668
+ - `message` - a human-readable description
669
+ - `deprecated` - the deprecated option or property name
670
+ - `replacement` - the name to use instead
671
+
672
+ **Invalid priority keys** (`type: "invalid-priority"`): `priorities` (and the deprecated `delays`) must be keyed by integers. A key that isn't one is reported instead of being dropped silently: a key that isn't numeric at all (`"high"`) is ignored, and a key with a fractional part (`"2.5"`) is applied to the truncated priority (`2`), as before:
673
+
674
+ - `type` - `"invalid-priority"`
675
+ - `message` - a human-readable description
676
+ - `option` - the option the key came from (`"priorities"` or `"delays"`)
677
+ - `key` - the key as written
678
+ - `priority` - the priority it was applied to, or `null` when it was ignored
623
679
 
624
680
  ```javascript
625
681
  const queue = new HoldMyTask({
626
- delays: { 1: 100 }, // Deprecated option
627
- coalescingWindowDuration: 200 // Deprecated option
682
+ delays: { 1: 100 }, // Deprecated: use priorities
683
+ coalescingWindowDuration: 200 // Deprecated: use coalescing.defaults.windowDuration
628
684
  });
629
685
 
630
686
  queue.on("warning", (warning) => {
631
- console.warn(`Deprecation Warning: ${warning.message}`);
632
- console.warn(`Use: ${warning.replacement}`);
633
- console.warn(`In: ${warning.source}`);
687
+ if (warning.type === "deprecation") {
688
+ console.warn(`${warning.message} (${warning.deprecated} -> ${warning.replacement})`);
689
+ }
634
690
  });
635
691
 
636
692
  // Output:
637
- // Deprecation Warning: Option 'delays' is deprecated
638
- // Use: priorities: { 1: { delay: 100 } }
639
- // In: constructor options
693
+ // Option 'coalescingWindowDuration' is deprecated. Use 'coalescing.defaults.windowDuration' instead. (coalescingWindowDuration -> coalescing.defaults.windowDuration)
694
+ // Option 'delays' is deprecated. Use 'priorities' instead with { [priority]: { postDelay: value, startDelay: 0 } } format. (delays -> priorities)
640
695
  ```
641
696
 
697
+ ### Deprecated Options
698
+
699
+ These names still work, but each emits a deprecation warning. Use the current names in new code:
700
+
701
+ | Deprecated | Use instead |
702
+ | ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
703
+ | `delays: { [priority]: ms }` | `priorities: { [priority]: { postDelay: ms } }` |
704
+ | `delay` in a `priorities` entry, `coalescing.defaults`, `coalescing.keys` entry, `configurePriority()` or `configureCoalescingKey()` | `postDelay` |
705
+ | `start` in the same places | `startDelay` |
706
+ | `delay` as a task option passed to `enqueue()` | `postDelay` |
707
+ | `start` as a task option passed to `enqueue()` | `startDelay` |
708
+ | `coalescingWindowDuration` (constructor) | `coalescing.defaults.windowDuration` |
709
+ | `coalescingMaxDelay` (constructor) | `coalescing.defaults.maxDelay` |
710
+ | `coalescingMultipleCallbacks` (constructor) | `coalescing.defaults.multipleCallbacks` |
711
+ | `coalescingResolveAllPromises` (constructor) | `coalescing.defaults.resolveAllPromises` |
712
+
713
+ Each task-level alias (`delay`, `start`) warns once per queue instance, not once per task. If both a deprecated alias and its replacement are given, the replacement wins. The per-task `coalescingWindowDuration` / `coalescingMaxDelay` / `coalescingMultipleCallbacks` / `coalescingResolveAllPromises` overrides are not deprecated and remain the current names for task options.
714
+
715
+ ---
716
+
642
717
  ## ⚙️ Concurrency & Delays Interaction
643
718
 
644
719
  Understanding how concurrency and delays work together is crucial for optimal queue behavior:
@@ -648,7 +723,7 @@ Understanding how concurrency and delays work together is crucial for optimal qu
648
723
  ```javascript
649
724
  const queue = new HoldMyTask({
650
725
  concurrency: 3, // Up to 3 tasks can run simultaneously
651
- delays: { 1: 500, 2: 1000 }
726
+ priorities: { 1: { postDelay: 500 }, 2: { postDelay: 1000 } }
652
727
  });
653
728
  ```
654
729
 
@@ -661,7 +736,7 @@ const queue = new HoldMyTask({
661
736
  ### Timing Examples
662
737
 
663
738
  ```javascript
664
- // Timeline with concurrency: 2, delays: { 1: 1000 }
739
+ // Timeline with concurrency: 2, priorities: { 1: { postDelay: 1000 } }
665
740
 
666
741
  // 10:00:00 - Start: TaskA (pri 1), TaskB (pri 1) - both running
667
742
  // 10:00:02 - TaskA completes → 1000ms delay starts, TaskB still running
@@ -709,10 +784,6 @@ HoldMyTask uses a sophisticated dual-heap scheduling system for optimal performa
709
784
 
710
785
  This architecture enables handling thousands of tasks with precise timing control while maintaining excellent performance.
711
786
 
712
- [![CodeFactor](https://img.shields.io/codefactor/grade/github/CLDMV/holdmytask?style=for-the-badge&logo=codefactor&logoColor=white&labelColor=F44A6A)](https://www.codefactor.io/repository/github/cldmv/holdmytask) [![npms.io score](https://img.shields.io/npms-io/final-score/%40cldmv%2Fholdmytask?style=for-the-badge&logo=npms&logoColor=white&labelColor=0B5D57)](https://npms.io/search?q=%40cldmv%2Fholdmytask)
713
-
714
- [![npm unpacked size](https://img.shields.io/npm/unpacked-size/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837)](https://www.npmjs.com/package/@cldmv/holdmytask) [![Repo size](https://img.shields.io/github/repo-size/CLDMV/holdmytask?style=for-the-badge&logo=github&logoColor=white&labelColor=181717)](https://github.com/CLDMV/holdmytask)
715
-
716
787
  ### Unlimited Queue Capacity
717
788
 
718
789
  For scenarios requiring unlimited task queuing, you can set `maxQueue` to `-1`:
@@ -740,6 +811,8 @@ for (let i = 0; i < 100000; i++) {
740
811
 
741
812
  While `-1` allows unlimited queuing, be mindful of memory usage with very large task sets. Each queued task consumes memory until executed.
742
813
 
814
+ ---
815
+
743
816
  ## 🎯 Advanced Features
744
817
 
745
818
  ### Priority System
@@ -769,50 +842,50 @@ HoldMyTask supports comprehensive priority and coalescing configuration for soph
769
842
  ```javascript
770
843
  const queue = new HoldMyTask({
771
844
  concurrency: 3,
772
- // Priority-specific defaults (replaces legacy delays)
845
+ // Priority-specific defaults
773
846
  priorities: {
774
- 1: { delay: 200, start: 0 }, // High priority: 200ms delay, immediate start
775
- 2: { delay: 100, start: 25 }, // Medium priority: 100ms delay, 25ms start delay
776
- 3: { delay: 50, start: 50 } // Low priority: 50ms delay, 50ms start delay
847
+ 1: { postDelay: 200, startDelay: 0 }, // High priority: 200ms delay, immediate start
848
+ 2: { postDelay: 100, startDelay: 25 }, // Medium priority: 100ms delay, 25ms start delay
849
+ 3: { postDelay: 50, startDelay: 50 } // Low priority: 50ms delay, 50ms start delay
777
850
  },
778
851
  // Enhanced coalescing with per-key settings
779
852
  coalescing: {
780
853
  defaults: {
781
854
  windowDuration: 200,
782
855
  maxDelay: 1000,
783
- delay: 75, // Default completion delay for coalescing tasks
784
- start: 25, // Default start delay for coalescing tasks
856
+ postDelay: 75, // Default completion delay for coalescing tasks
857
+ startDelay: 25, // Default start delay for coalescing tasks
785
858
  resolveAllPromises: true
786
859
  },
787
860
  keys: {
788
861
  "ui.update": {
789
862
  windowDuration: 100,
790
863
  maxDelay: 500,
791
- delay: 25, // Fast UI updates
792
- start: 0
864
+ postDelay: 25, // Fast UI updates
865
+ startDelay: 0
793
866
  },
794
867
  "api.batch": {
795
868
  windowDuration: 1000,
796
869
  maxDelay: 5000,
797
- delay: 200, // Slower API operations
798
- start: 100
870
+ postDelay: 200, // Slower API operations
871
+ startDelay: 100
799
872
  }
800
873
  }
801
874
  }
802
875
  });
803
876
 
804
877
  // Dynamic configuration
805
- queue.configurePriority(4, { delay: 300, start: 75 });
878
+ queue.configurePriority(4, { postDelay: 300, startDelay: 75 });
806
879
  queue.configureCoalescingKey("data.sync", {
807
880
  windowDuration: 800,
808
881
  maxDelay: 3000,
809
- delay: 150,
810
- start: 50
882
+ postDelay: 150,
883
+ startDelay: 50
811
884
  });
812
885
 
813
886
  // Get configuration information
814
887
  const priority4Config = queue.getPriorityConfig(4);
815
- console.log(`Priority 4: ${priority4Config.delay}ms delay, ${priority4Config.start}ms start delay`);
888
+ console.log(`Priority 4: ${priority4Config.postDelay}ms delay, ${priority4Config.startDelay}ms start delay`);
816
889
 
817
890
  const dataSyncConfig = queue.getCoalescingConfig("data.sync");
818
891
  console.log(`Data sync: ${dataSyncConfig.windowDuration}ms window, ${dataSyncConfig.maxDelay}ms max delay`);
@@ -832,7 +905,7 @@ console.log("All coalescing configs:", allCoalescingKeys);
832
905
  4. Coalescing defaults
833
906
  5. System defaults (lowest priority)
834
907
 
835
- **Backward Compatibility:** Legacy `delays` options are automatically converted to the new `priorities` format.
908
+ **Backward Compatibility:** Deprecated option names are converted automatically; see [Deprecated Options](#deprecated-options).
836
909
 
837
910
  ### Smart Scheduling
838
911
 
@@ -983,10 +1056,10 @@ Priority delays create "cool-down" periods after task completion based on the co
983
1056
  ```javascript
984
1057
  const queue = new HoldMyTask({
985
1058
  concurrency: 1,
986
- delays: {
987
- 1: 1000, // 1 second delay after priority 1 tasks complete
988
- 2: 500, // 500ms delay after priority 2 tasks complete
989
- 3: 0 // No delay after priority 3 tasks (explicit)
1059
+ priorities: {
1060
+ 1: { postDelay: 1000 }, // 1 second delay after priority 1 tasks complete
1061
+ 2: { postDelay: 500 }, // 500ms delay after priority 2 tasks complete
1062
+ 3: { postDelay: 0 } // No delay after priority 3 tasks (explicit)
990
1063
  }
991
1064
  });
992
1065
 
@@ -997,22 +1070,22 @@ const queue = new HoldMyTask({
997
1070
  // → Next task can't start until 10:00:07.5 (500ms delay)
998
1071
 
999
1072
  // Override delay for specific task
1000
- queue.enqueue(task, callback, { priority: 1, delay: 200 }); // Uses 200ms instead of 1000ms
1073
+ queue.enqueue(task, callback, { priority: 1, postDelay: 200 }); // Uses 200ms instead of 1000ms
1001
1074
 
1002
1075
  // Set zero delay for specific task
1003
- queue.enqueue(task, callback, { priority: 1, delay: 0 }); // No delay after this task
1076
+ queue.enqueue(task, callback, { priority: 1, postDelay: 0 }); // No delay after this task
1004
1077
  ```
1005
1078
 
1006
1079
  ### Delay Bypass - Emergency Task Injection
1007
1080
 
1008
- When urgent tasks need to execute immediately, bypassing active delay periods, use the `bypassDelay` option or `delay: -1` syntax. This is perfect for emergency situations, high-priority interrupts, or critical system tasks.
1081
+ When urgent tasks need to execute immediately, bypassing active delay periods, use the `bypassDelay` option or `postDelay: -1` syntax. This is perfect for emergency situations, high-priority interrupts, or critical system tasks.
1009
1082
 
1010
1083
  #### Bypass Behavior
1011
1084
 
1012
1085
  ```javascript
1013
1086
  const queue = new HoldMyTask({
1014
1087
  concurrency: 1,
1015
- delays: { 1: 1000 } // 1 second delay after priority 1 tasks
1088
+ priorities: { 1: { postDelay: 1000 } } // 1 second delay after priority 1 tasks
1016
1089
  });
1017
1090
 
1018
1091
  // Timeline example:
@@ -1030,7 +1103,7 @@ queue.enqueue(urgentTaskC, callback, {
1030
1103
  // Alternative bypass syntax
1031
1104
  queue.enqueue(emergencyTaskD, callback, {
1032
1105
  priority: 1,
1033
- delay: -1 // Same as bypassDelay: true
1106
+ postDelay: -1 // Same as bypassDelay: true
1034
1107
  });
1035
1108
  ```
1036
1109
 
@@ -1039,7 +1112,7 @@ queue.enqueue(emergencyTaskD, callback, {
1039
1112
  ```javascript
1040
1113
  const queue = new HoldMyTask({
1041
1114
  concurrency: 2,
1042
- delays: { 1: 800, 2: 400 }
1115
+ priorities: { 1: { postDelay: 800 }, 2: { postDelay: 400 } }
1043
1116
  });
1044
1117
 
1045
1118
  // Multiple tasks with different bypass behavior
@@ -1059,6 +1132,8 @@ queue.enqueue(taskD, callback, { priority: 1 }); // Waits for taskC's completion
1059
1132
  - ✅ **Concurrency aware** - works correctly with multiple concurrent execution slots
1060
1133
  - ⚠️ **Use sparingly** - frequent bypassing defeats the purpose of delay-based rate limiting
1061
1134
 
1135
+ ---
1136
+
1062
1137
  ## 🔄 Task Coalescing System
1063
1138
 
1064
1139
  The coalescing system allows multiple similar tasks to be intelligently merged, reducing redundant operations while ensuring all promises resolve with accurate results. This is perfect for scenarios like UI updates, API calls, or device commands where only the final result matters.
@@ -1072,7 +1147,7 @@ When tasks with the same `coalescingKey` are enqueued within a time window, they
1072
1147
  3. **One representative task** executes for the entire group
1073
1148
  4. **All promises** in the group resolve with the same result
1074
1149
 
1075
- ⚠️ **Critical Timing Consideration**: Real-world tasks take time to execute (100ms-2000ms+). If your coalescing tasks need to see the final state from other operations, ensure proper timing with `start` delays or `timestamp` scheduling. Tasks that start too early may see intermediate states rather than final results.
1150
+ ⚠️ **Critical Timing Consideration**: Real-world tasks take time to execute (100ms-2000ms+). If your coalescing tasks need to see the final state from other operations, ensure proper timing with `startDelay` or `timestamp` scheduling. Tasks that start too early may see intermediate states rather than final results.
1076
1151
 
1077
1152
  ### 🎯 Correct Coalescing Pattern: Fire-and-Forget with Embedded Updates
1078
1153
 
@@ -1121,9 +1196,13 @@ function volumeUp() {
1121
1196
  ```javascript
1122
1197
  const queue = new HoldMyTask({
1123
1198
  concurrency: 1,
1124
- coalescingWindowDuration: 200, // 200ms window for grouping tasks
1125
- coalescingMaxDelay: 1000, // Maximum 1000ms delay before forcing execution
1126
- coalescingResolveAllPromises: true // All promises get the result (default: true)
1199
+ coalescing: {
1200
+ defaults: {
1201
+ windowDuration: 200, // 200ms window for grouping tasks
1202
+ maxDelay: 1000, // Maximum 1000ms delay before forcing execution
1203
+ resolveAllPromises: true // All promises get the result (default: true)
1204
+ }
1205
+ }
1127
1206
  });
1128
1207
  ```
1129
1208
 
@@ -1143,7 +1222,7 @@ async function updateVolume(change) {
1143
1222
  {
1144
1223
  coalescingKey: "volume.update", // Tasks with same key get grouped
1145
1224
  priority: 1,
1146
- delay: 100 // 100ms delay after completion
1225
+ postDelay: 100 // 100ms delay after completion
1147
1226
  }
1148
1227
  );
1149
1228
  }
@@ -1169,8 +1248,12 @@ The correct pattern for coalescing with updates is to enqueue update tasks **fro
1169
1248
  ```javascript
1170
1249
  const queue = new HoldMyTask({
1171
1250
  concurrency: 2, // Allow volume and update tasks to run concurrently
1172
- coalescingWindowDuration: 200,
1173
- coalescingMaxDelay: 1000
1251
+ coalescing: {
1252
+ defaults: {
1253
+ windowDuration: 200,
1254
+ maxDelay: 1000
1255
+ }
1256
+ }
1174
1257
  });
1175
1258
 
1176
1259
  // Volume commands using fire-and-forget pattern
@@ -1197,7 +1280,7 @@ function volumeUp(amount = 1) {
1197
1280
  {
1198
1281
  coalescingKey: "volume.ui.update", // UI updates get coalesced
1199
1282
  priority: 5, // Lower priority than volume commands
1200
- delay: 100 // Brief delay after UI updates
1283
+ postDelay: 100 // Brief delay after UI updates
1201
1284
  }
1202
1285
  );
1203
1286
 
@@ -1205,7 +1288,7 @@ function volumeUp(amount = 1) {
1205
1288
  },
1206
1289
  {
1207
1290
  priority: 1, // High priority for user actions
1208
- delay: 100 // Brief delay after volume operations
1291
+ postDelay: 100 // Brief delay after volume operations
1209
1292
  }
1210
1293
  );
1211
1294
  }
@@ -1238,7 +1321,7 @@ async function processDataBatch(data) {
1238
1321
  {
1239
1322
  coalescingKey: "api.batch.process",
1240
1323
  priority: 2,
1241
- start: 100 // 100ms delay allows grouping
1324
+ startDelay: 100 // 100ms delay allows grouping
1242
1325
  }
1243
1326
  );
1244
1327
  }
@@ -1255,12 +1338,16 @@ async function processDataBatch(data) {
1255
1338
 
1256
1339
  ### Coalescing with Explicit Timestamps
1257
1340
 
1258
- For precise scheduling, use `timestamp` instead of `start`:
1341
+ For precise scheduling, use `timestamp` instead of `startDelay`:
1259
1342
 
1260
1343
  ```javascript
1261
1344
  const queue = new HoldMyTask({
1262
- coalescingWindowDuration: 300,
1263
- coalescingMaxDelay: 2000
1345
+ coalescing: {
1346
+ defaults: {
1347
+ windowDuration: 300,
1348
+ maxDelay: 2000
1349
+ }
1350
+ }
1264
1351
  });
1265
1352
 
1266
1353
  // Schedule all updates for the same exact time
@@ -1294,8 +1381,12 @@ Control maximum delay with `mustRunBy` to ensure tasks don't wait too long:
1294
1381
 
1295
1382
  ```javascript
1296
1383
  const queue = new HoldMyTask({
1297
- coalescingWindowDuration: 500, // Try to group for 500ms
1298
- coalescingMaxDelay: 2000 // But never wait more than 2 seconds
1384
+ coalescing: {
1385
+ defaults: {
1386
+ windowDuration: 500, // Try to group for 500ms
1387
+ maxDelay: 2000 // But never wait more than 2 seconds
1388
+ }
1389
+ }
1299
1390
  });
1300
1391
 
1301
1392
  // Critical system updates
@@ -1324,8 +1415,12 @@ Control how promises resolve within coalescing groups:
1324
1415
 
1325
1416
  ```javascript
1326
1417
  const queue = new HoldMyTask({
1327
- coalescingResolveAllPromises: true, // Default: all promises get the result
1328
- coalescingWindowDuration: 200
1418
+ coalescing: {
1419
+ defaults: {
1420
+ resolveAllPromises: true, // Default: all promises get the result
1421
+ windowDuration: 200
1422
+ }
1423
+ }
1329
1424
  });
1330
1425
 
1331
1426
  // Mode 1: All promises resolve (default behavior)
@@ -1336,18 +1431,23 @@ const results1 = await Promise.all([
1336
1431
  ]);
1337
1432
  // All three promises resolve with the same result
1338
1433
 
1339
- // Mode 2: Only representative promise resolves
1434
+ // Mode 2: Only the representative (newest) task's promise resolves
1340
1435
  const queue2 = new HoldMyTask({
1341
- coalescingResolveAllPromises: false,
1342
- coalescingWindowDuration: 200
1436
+ coalescing: {
1437
+ defaults: {
1438
+ resolveAllPromises: false,
1439
+ windowDuration: 200
1440
+ }
1441
+ }
1343
1442
  });
1344
1443
 
1345
- const [result1, result2, result3] = await Promise.all([
1346
- queue2.enqueue(task, { coalescingKey: "test" }), // Resolves with result
1347
- queue2.enqueue(task, { coalescingKey: "test" }), // Resolves with undefined
1348
- queue2.enqueue(task, { coalescingKey: "test" }) // Resolves with undefined
1444
+ const settled = await Promise.allSettled([
1445
+ queue2.enqueue(task, { coalescingKey: "test" }), // Rejects: "Task was coalesced with a newer task"
1446
+ queue2.enqueue(task, { coalescingKey: "test" }), // Rejects: "Task was coalesced with a newer task"
1447
+ queue2.enqueue(task, { coalescingKey: "test" }) // Resolves with the result
1349
1448
  ]);
1350
- // Only the first (representative) promise gets the actual result
1449
+ // Only the newest task in the group gets the result; the others are rejected
1450
+ // (callback-style tasks receive the same error as their first argument)
1351
1451
  ```
1352
1452
 
1353
1453
  ### Real-World Coalescing Patterns
@@ -1359,8 +1459,12 @@ class VolumeController {
1359
1459
  constructor() {
1360
1460
  this.queue = new HoldMyTask({
1361
1461
  concurrency: 2, // Allow volume and update tasks concurrently
1362
- coalescingWindowDuration: 200,
1363
- coalescingMaxDelay: 1000
1462
+ coalescing: {
1463
+ defaults: {
1464
+ windowDuration: 200,
1465
+ maxDelay: 1000
1466
+ }
1467
+ }
1364
1468
  });
1365
1469
  }
1366
1470
 
@@ -1383,7 +1487,7 @@ class VolumeController {
1383
1487
  {
1384
1488
  coalescingKey: "volume.ui.update", // Updates coalesce together
1385
1489
  priority: 3, // Lower priority than volume changes
1386
- delay: 100 // Brief delay after UI updates
1490
+ postDelay: 100 // Brief delay after UI updates
1387
1491
  }
1388
1492
  );
1389
1493
 
@@ -1391,7 +1495,7 @@ class VolumeController {
1391
1495
  },
1392
1496
  {
1393
1497
  priority: 1, // High priority for user actions
1394
- delay: 50 // Brief delay between volume operations
1498
+ postDelay: 50 // Brief delay between volume operations
1395
1499
  }
1396
1500
  );
1397
1501
  }
@@ -1405,8 +1509,12 @@ class APIBatcher {
1405
1509
  constructor() {
1406
1510
  this.queue = new HoldMyTask({
1407
1511
  concurrency: 2,
1408
- coalescingWindowDuration: 300,
1409
- coalescingMaxDelay: 1500
1512
+ coalescing: {
1513
+ defaults: {
1514
+ windowDuration: 300,
1515
+ maxDelay: 1500
1516
+ }
1517
+ }
1410
1518
  });
1411
1519
  }
1412
1520
 
@@ -1436,8 +1544,12 @@ Real-world performance improvements with the embedded update pattern:
1436
1544
  // Fire-and-forget pattern with embedded coalescing updates
1437
1545
  const queue = new HoldMyTask({
1438
1546
  concurrency: 2,
1439
- coalescingWindowDuration: 200,
1440
- coalescingMaxDelay: 1000
1547
+ coalescing: {
1548
+ defaults: {
1549
+ windowDuration: 200,
1550
+ maxDelay: 1000
1551
+ }
1552
+ }
1441
1553
  });
1442
1554
 
1443
1555
  // Volume control example - realistic embedded pattern
@@ -1476,9 +1588,11 @@ function processVolumeCommands() {
1476
1588
  // - Total time: ~25-30 seconds (vs 50+ seconds without coalescing)
1477
1589
  ```
1478
1590
 
1479
- ### Timeouts
1591
+ ---
1592
+
1593
+ ## ⏱️ Timeouts
1480
1594
 
1481
- Tasks automatically timeout and either call the callback with an error or reject the promise:
1595
+ Tasks automatically time out and either call the callback with an error payload or reject the promise. Callback-style timeouts also emit an `error` event on the queue (see [Events](#events)):
1482
1596
 
1483
1597
  **Callback API:**
1484
1598
 
@@ -1518,6 +1632,8 @@ try {
1518
1632
  }
1519
1633
  ```
1520
1634
 
1635
+ ---
1636
+
1521
1637
  ## 🛑 AbortController Support
1522
1638
 
1523
1639
  The library uses `AbortController` for cooperative task cancellation. This allows tasks to be cancelled gracefully without forcing termination.
@@ -1679,6 +1795,8 @@ try {
1679
1795
  - **Cooperative**: Tasks must actively check and respond to the abort signal
1680
1796
  - **Async operations**: Only cancellable if the underlying operation supports AbortSignal
1681
1797
 
1798
+ ---
1799
+
1682
1800
  ## 📝 Examples
1683
1801
 
1684
1802
  ### Basic Usage
@@ -1712,10 +1830,10 @@ function processUser(userId) {
1712
1830
  ```javascript
1713
1831
  const queue = new HoldMyTask({
1714
1832
  concurrency: 1,
1715
- delays: {
1716
- 1: 1000, // 1 second between high-priority tasks
1717
- 2: 100, // 100ms between medium-priority tasks
1718
- 3: 0 // No delay for low-priority tasks
1833
+ priorities: {
1834
+ 1: { postDelay: 1000 }, // 1 second between high-priority tasks
1835
+ 2: { postDelay: 100 }, // 100ms between medium-priority tasks
1836
+ 3: { postDelay: 0 } // No delay for low-priority tasks
1719
1837
  }
1720
1838
  });
1721
1839
 
@@ -1732,7 +1850,7 @@ queue.enqueue(mediumTask2, callback, { priority: 2 });
1732
1850
  ```javascript
1733
1851
  const queue = new HoldMyTask({
1734
1852
  concurrency: 5,
1735
- delays: { 1: 50 } // Small delay between batches
1853
+ priorities: { 1: { postDelay: 50 } } // Small delay between batches
1736
1854
  });
1737
1855
 
1738
1856
  async function processBatch(items) {
@@ -1767,10 +1885,10 @@ Real-world scenario: API rate limiting with emergency override capability.
1767
1885
  ```javascript
1768
1886
  const apiQueue = new HoldMyTask({
1769
1887
  concurrency: 2,
1770
- delays: {
1771
- 1: 2000, // 2 second delay between API calls (rate limiting)
1772
- 2: 5000, // 5 second delay for heavy operations
1773
- 9: 0 // No delay for monitoring tasks
1888
+ priorities: {
1889
+ 1: { postDelay: 2000 }, // 2 second delay between API calls (rate limiting)
1890
+ 2: { postDelay: 5000 }, // 5 second delay for heavy operations
1891
+ 9: { postDelay: 0 } // No delay for monitoring tasks
1774
1892
  }
1775
1893
  });
1776
1894
 
@@ -1793,7 +1911,7 @@ apiQueue.enqueue(processSecurityAlert, handleEmergency, {
1793
1911
  // Alternative syntax for bypass
1794
1912
  apiQueue.enqueue(emergencyShutdown, handleEmergency, {
1795
1913
  priority: 1,
1796
- delay: -1, // Same as bypassDelay: true
1914
+ postDelay: -1, // Same as bypassDelay: true
1797
1915
  metadata: { action: "shutdown" }
1798
1916
  });
1799
1917
 
@@ -1813,23 +1931,26 @@ setInterval(() => {
1813
1931
  }, 1000);
1814
1932
  ```
1815
1933
 
1934
+ ---
1935
+
1816
1936
  ## 🧪 Testing & Development
1817
1937
 
1818
1938
  ```bash
1819
- # Run tests
1939
+ # Run tests (vitest suite + CommonJS entry tests)
1820
1940
  npm test
1821
1941
 
1822
1942
  # Run tests with coverage
1823
- npm run test:coverage
1943
+ npm run coverage
1824
1944
 
1825
1945
  # Run tests in watch mode
1826
- npm run test:run
1946
+ npm run test:watch
1827
1947
 
1828
- # Lint code
1948
+ # Lint and format check
1829
1949
  npm run lint
1950
+ npm run format:check
1830
1951
 
1831
- # Build for publishing
1832
- npm run build
1952
+ # Build types, type-check, and build for publishing
1953
+ npm run build:ci
1833
1954
  ```
1834
1955
 
1835
1956
  ### Testing with Injectable Clock
@@ -1853,21 +1974,74 @@ console.log(Date.now()); // Returns actual system time
1853
1974
  queue.enqueue(task, { timestamp: queue.now() + 5000 }); // 5 seconds from mock time
1854
1975
  ```
1855
1976
 
1856
- ## 📄 License
1977
+ ---
1978
+
1979
+ ## 📚 Documentation
1980
+
1981
+ - **[Changelog](https://github.com/CLDMV/holdmytask/tree/master/docs/changelog/)** — release notes for every version (v1 + v2)
1982
+ - **[Examples](https://github.com/CLDMV/holdmytask/tree/master/examples/)** — runnable scripts exercising priorities, coalescing, and stress scenarios
1983
+ - **[Type definitions](https://github.com/CLDMV/holdmytask/tree/master/types/)** — the TypeScript declarations shipped with the package
1857
1984
 
1858
- [![GitHub license](https://img.shields.io/github/license/CLDMV/holdmytask.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717)](https://github.com/CLDMV/holdmytask/blob/HEAD/LICENSE) [![npm license](https://img.shields.io/npm/l/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837)](https://www.npmjs.com/package/@cldmv/holdmytask)
1985
+ [![CodeFactor]][codefactor_url] [![OpenSSF Scorecard]][ossf_scorecard_url] [![npms.io score]][npms_url] [![npm unpacked size]][npm_size_url] [![Repo size]][repo_size_url]
1859
1986
 
1860
- Apache License 2.0 - see [LICENSE](LICENSE) file for details.
1987
+ ---
1861
1988
 
1862
1989
  ## 🤝 Contributing
1863
1990
 
1864
- Contributions welcome! Please ensure:
1991
+ Contributions are welcome! Please ensure:
1865
1992
 
1866
1993
  - All tests pass
1867
1994
  - Code follows existing style
1868
1995
  - New features include tests
1869
1996
  - Documentation is updated
1870
1997
 
1998
+ [![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
1999
+
1871
2000
  ---
1872
2001
 
1873
- **Made with ❤️ for robust task management**
2002
+ ## 🔗 Links
2003
+
2004
+ - **npm**: [@cldmv/holdmytask](https://www.npmjs.com/package/@cldmv/holdmytask)
2005
+ - **GitHub**: [CLDMV/holdmytask](https://github.com/CLDMV/holdmytask)
2006
+ - **Issues**: [GitHub Issues](https://github.com/CLDMV/holdmytask/issues)
2007
+ - **Changelog**: [docs/changelog/](https://github.com/CLDMV/holdmytask/tree/master/docs/changelog/)
2008
+ - **Releases**: [GitHub Releases](https://github.com/CLDMV/holdmytask/releases)
2009
+
2010
+ ---
2011
+
2012
+ ## 📄 License
2013
+
2014
+ [![GitHub license]][github_license_url] [![npm license]][npm_license_url]
2015
+
2016
+ Apache-2.0 © Shinrai / CLDMV — see [LICENSE](https://github.com/CLDMV/holdmytask/blob/HEAD/LICENSE) for details.
2017
+
2018
+ [npm version]: https://img.shields.io/npm/v/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
2019
+ [npm_version_url]: https://www.npmjs.com/package/@cldmv/holdmytask
2020
+ [last commit]: https://img.shields.io/github/last-commit/CLDMV/holdmytask?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
2021
+ [last_commit_url]: https://github.com/CLDMV/holdmytask/commits
2022
+ [npm last update]: https://img.shields.io/npm/last-update/%40cldmv%2Fholdmytask?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
2023
+ [npm_last_update_url]: https://www.npmjs.com/package/@cldmv/holdmytask
2024
+ [codefactor]: https://img.shields.io/codefactor/grade/github/CLDMV/holdmytask?style=for-the-badge&logo=codefactor&logoColor=white&labelColor=F44A6A
2025
+ [codefactor_url]: https://www.codefactor.io/repository/github/cldmv/holdmytask
2026
+ [openssf scorecard]: https://img.shields.io/ossf-scorecard/github.com/CLDMV/holdmytask?style=for-the-badge&label=OpenSSF%20Scorecard
2027
+ [ossf_scorecard_url]: https://scorecard.dev/viewer/?uri=github.com/CLDMV/holdmytask
2028
+ [npms.io score]: https://img.shields.io/npms-io/final-score/%40cldmv%2Fholdmytask?style=for-the-badge&logo=npms&logoColor=white&labelColor=0B5D57
2029
+ [npms_url]: https://npms.io/search?q=%40cldmv%2Fholdmytask
2030
+ [npm downloads]: https://img.shields.io/npm/dm/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
2031
+ [npm_downloads_url]: https://www.npmjs.com/package/@cldmv/holdmytask
2032
+ [github downloads]: https://img.shields.io/github/downloads/CLDMV/holdmytask/total?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
2033
+ [github_downloads_url]: https://github.com/CLDMV/holdmytask/releases
2034
+ [npm unpacked size]: https://img.shields.io/npm/unpacked-size/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
2035
+ [npm_size_url]: https://www.npmjs.com/package/@cldmv/holdmytask
2036
+ [repo size]: https://img.shields.io/github/repo-size/CLDMV/holdmytask?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
2037
+ [repo_size_url]: https://github.com/CLDMV/holdmytask
2038
+ [github license]: https://img.shields.io/github/license/CLDMV/holdmytask.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
2039
+ [github_license_url]: https://github.com/CLDMV/holdmytask/blob/HEAD/LICENSE
2040
+ [npm license]: https://img.shields.io/npm/l/%40cldmv%2Fholdmytask.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
2041
+ [npm_license_url]: https://www.npmjs.com/package/@cldmv/holdmytask
2042
+ [coverage]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FCLDMV%2Fholdmytask%2Fbadges%2Fcoverage.json&style=for-the-badge&logo=vitest&logoColor=white
2043
+ [coverage_url]: https://github.com/CLDMV/holdmytask/blob/badges/coverage.json
2044
+ [contributors]: https://img.shields.io/github/contributors/CLDMV/holdmytask.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
2045
+ [contributors_url]: https://github.com/CLDMV/holdmytask/graphs/contributors
2046
+ [sponsor shinrai]: https://img.shields.io/github/sponsors/shinrai?style=for-the-badge&logo=githubsponsors&logoColor=white&labelColor=EA4AAA&label=Sponsor
2047
+ [sponsor_url]: https://github.com/sponsors/shinrai