Skip to content

Commit 163e869

Browse files
committed
Bump version to v2.0.2: README improvements, added a Table of Contents for easier navigation
1 parent 752d25b commit 163e869

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,35 @@ Key features include:
77
* __Status Communication__: Easily check the current status of the scheduled task.
88
* __Graceful Termination__: Await the completion of an ongoing execution, ensuring deterministic termination when needed.
99

10-
This class is ideal for scenarios where precise control over the execution and termination of asynchronous tasks is required.
10+
This class is ideal for scenarios where precise control over the execution and termination of asynchronous tasks is required. If you need to manage **multiple** asynchronous tasks, potentially in large numbers, consider the [delayed-async-tasks-manager](https://www.npmjs.com/package/delayed-async-tasks-manager) package, which extends the functionality of this package.
1111

12-
## Key Features :sparkles:
12+
## Table of Contents
13+
14+
* [Key Features](#key-features)
15+
* [API](#api)
16+
* [Execution Status Getters](#execution-status-getters)
17+
* [Graceful and Deterministic Termination](#graceful-termination)
18+
* [Zero Over-Engineering, No External Dependencies](#no-external-dependencies)
19+
* [Non-Persistent Scheduling](#non-persistent)
20+
* [Error Handling](#error-handling)
21+
* [Use-case Example](#use-case-example)
22+
* [Breaking Change in Version 2.0.0](#breaking-change-2)
23+
* [License](#license)
24+
25+
## Key Features :sparkles:<a id="key-features"></a>
1326

1427
* __Modern Substitute for Javascript's 'setTimeout'__: Specifically designed for scheduling asynchronous tasks.
15-
* __Execution Status Getters__: Allows users to check the task's execution status, helping to prevent potential race conditions.
16-
* __Graceful and Deterministic Termination__: The `awaitCompletionIfCurrentlyExecuting` method resolves once the currently executing task finishes, or resolves immediately if the task is not executing.
17-
* __Robust Error Handling__: If the task throws an uncaught error, the error is captured and accessible via the `uncaughtRejection` getter.
28+
* __Execution Status Getters :bar_chart:__: Allows users to check the task's execution status, helping to prevent potential race conditions.
29+
* __Graceful and Deterministic Termination :hourglass:__: The `awaitCompletionIfCurrentlyExecuting` method resolves once the currently executing task finishes, or resolves immediately if the task is not executing.
30+
* __Robust Error Handling :warning:__: If the task throws an uncaught error, the error is captured and accessible via the `uncaughtRejection` getter.
1831
* __Comprehensive Documentation :books:__: The class is thoroughly documented, enabling IDEs to provide helpful tooltips that enhance the coding experience.
1932
* __Fully Tested :test_tube:__: Extensively covered by unit tests.
2033
* __No External Runtime Dependencies__: Lightweight component, only development dependencies are used.
2134
* Non-Durable Scheduling: Scheduling stops if the application crashes or goes down.
2235
* ES2020 Compatibility.
2336
* TypeScript support.
2437

25-
## API
38+
## API :globe_with_meridians:<a id="api"></a>
2639

2740
The `DelayedAsyncTask` class provides the following methods:
2841

@@ -31,7 +44,7 @@ The `DelayedAsyncTask` class provides the following methods:
3144

3245
If needed, refer to the code documentation for a more comprehensive description of each method.
3346

34-
## Execution Status Getters :rocket:
47+
## Execution Status Getters :mag:<a id="execution-status-getters"></a>
3548

3649
The `DelayedAsyncTask` class provides five getter methods to communicate the task's status to users:
3750

@@ -41,7 +54,7 @@ The `DelayedAsyncTask` class provides five getter methods to communicate the tas
4154
* `isCompleted`: Indicates that the task has completed.
4255
* `isUncaughtRejectionOccurred`: Indicates that the task threw an uncaught error. The error can be accessed using the `uncaughtRejection` getter.
4356

44-
## Graceful and Deterministic Termination :hourglass:
57+
## Graceful and Deterministic Termination :hourglass:<a id="graceful-termination"></a>
4558

4659
In the context of asynchronous tasks and schedulers, graceful and deterministic termination is **often overlooked**. `DelayedAsyncTask` provides an out-of-the-box mechanism to await the completion of an asynchronous task that has already started but not yet finished, via the `awaitCompletionIfCurrentlyExecuting` method.
4760

@@ -100,17 +113,17 @@ class Component {
100113

101114
Another scenario where this feature is highly recommended is when a schedule might be aborted, such as in an abort-and-reschedule situation. If the task is currently executing, you may not be able to abort it. In such cases, you can ignore the reschedule request, await the current execution to complete, or implement any other business logic that suits your requirements.
102115

103-
## Zero Over-Engineering, No External Dependencies
116+
## Zero Over-Engineering, No External Dependencies<a id="no-external-dependencies"></a>
104117

105118
This component provides a lightweight, dependency-free solution. It is designed to be simple and efficient, ensuring minimal overhead. Additionally, it can serve as a building block for more advanced implementations, such as a Delayed Async Tasks Manager, if needed.
106119

107-
## Non-Persistent Scheduling
120+
## Non-Persistent Scheduling<a id="non-persistent"></a>
108121

109122
This component features non-durable scheduling, which means that if the app crashes or goes down, scheduling stops.
110123

111124
If you need to guarantee durability over a multi-node deployment, consider using this scheduler as a building block or use other custom-made solutions for that purpose.
112125

113-
## Error Handling :warning:
126+
## Error Handling :warning:<a id="error-handling"></a>
114127

115128
Unlike `setTimeout` in Node.js, where errors from rejected promises propagate to the event loop and trigger an `uncaughtRejection` event, this package offers robust error handling:
116129

@@ -119,7 +132,7 @@ Unlike `setTimeout` in Node.js, where errors from rejected promises propagate to
119132

120133
Ideally, a delayed task should handle its own errors and **avoid** throwing uncaught exceptions.
121134

122-
## Use-case Example :man_technologist:
135+
## Use-case Example :man_technologist:<a id="use-case-example"></a>
123136

124137
Consider a Background Updates Manager. For simplicity, we assume that updates occur only following an on-demand request by the admin, triggered by the execution of the `scheduleNextJob` method. Additionally, assume that only one future background update task can be scheduled at any given time. This means that scheduling a new task will abort any previously scheduled task that has not yet started.
125138

@@ -180,10 +193,10 @@ class BackgroundUpdatesManager {
180193
}
181194
```
182195

183-
## Breaking Change in Version 2.0.0
196+
## Breaking Change in Version 2.0.0 :boom:<a id="breaking-change-2"></a>
184197

185198
In version 2.0.0, the target compatibility has been upgraded from ES6 to ES2020. This change was made to leverage the widespread adoption of ES2020, in particular its native support for async/await.
186199

187-
## License :scroll:
200+
## License :scroll:<a id="license"></a>
188201

189202
[MIT](LICENSE)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "delayed-async-task",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A modern `setTimeout` substitute tailored for asynchronous tasks, designed to schedule a single delayed execution. Features status getters to communicate the execution status, the ability to abort a pending execution, and the option to gracefully await the completion of an ongoing execution.",
55
"repository": {
66
"type": "git",
@@ -34,6 +34,12 @@
3434
"one-time",
3535
"onetime-execution",
3636
"single-execution",
37+
"graceful-termination",
38+
"graceful-shutdown",
39+
"graceful-completion",
40+
"deterministic-termination",
41+
"deterministic-shutdown",
42+
"deterministic-completion",
3743
"typescript",
3844
"ts",
3945
"dangling-promise",

0 commit comments

Comments
 (0)