time-queues 1.2.0 → 1.2.2
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 +12 -11
- package/package.json +1 -1
- package/src/Counter.js +9 -6
- package/src/index.d.ts +1 -0
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
[npm-img]: https://img.shields.io/npm/v/time-queues.svg
|
|
4
4
|
[npm-url]: https://npmjs.org/package/time-queues
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
`time-queues` is an efficient, lightweight library for organizing asynchronous multitasking and scheduled tasks in JavaScript applications. It works seamlessly in browsers and server-side environments like Node.js, Deno, and Bun.
|
|
8
7
|
|
|
9
8
|
The library provides elegant solutions for common timing and scheduling challenges, helping developers create responsive, efficient applications that follow best practices for resource management and user experience.
|
|
@@ -62,13 +61,15 @@ This project is licensed under the BSD-3-Clause License.
|
|
|
62
61
|
|
|
63
62
|
## Release History
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
- 1.2.2 _`Counter`: separated old waiter from new waiters before notifying them._
|
|
65
|
+
- 1.2.1 _Minor release: updated formal TS dependencies in `index.d.ts`._
|
|
66
|
+
- 1.2.0 _Added `Counter`. Updated dev dependencies._
|
|
67
|
+
- 1.1.2 _Updated dev dependencies. No need to upgrade._
|
|
68
|
+
- 1.1.1 _Updates to TS typings._
|
|
69
|
+
- 1.1.0 _Added `Throttler`, `Retainer`, promise-based convenience time methods._
|
|
70
|
+
- 1.0.5 _Technical release: updated deps, more tests._
|
|
71
|
+
- 1.0.4 _Bug fixes and code simplifications._
|
|
72
|
+
- 1.0.3 _Updated deps (`list-toolkit`) to fix a minor bug._
|
|
73
|
+
- 1.0.2 _Updated deps (`list-toolkit`)._
|
|
74
|
+
- 1.0.1 _Minor update in README. No need to upgrade._
|
|
75
|
+
- 1.0.0 _Initial release._
|
package/package.json
CHANGED
package/src/Counter.js
CHANGED
|
@@ -45,25 +45,28 @@ export class Counter {
|
|
|
45
45
|
|
|
46
46
|
clearWaiters() {
|
|
47
47
|
if (this.zeroWaiters.length > 0) {
|
|
48
|
-
|
|
48
|
+
const zeroWaiters = this.zeroWaiters;
|
|
49
|
+
this.zeroWaiters = [];
|
|
50
|
+
for (const resolve of zeroWaiters) {
|
|
49
51
|
resolve(NaN);
|
|
50
52
|
}
|
|
51
|
-
this.zeroWaiters = [];
|
|
52
53
|
}
|
|
53
54
|
if (this.functionWaiters.size > 0) {
|
|
54
|
-
|
|
55
|
+
const functionWaiters = this.functionWaiters;
|
|
56
|
+
this.functionWaiters = new Set();
|
|
57
|
+
for (const {resolve} of functionWaiters) {
|
|
55
58
|
resolve(NaN);
|
|
56
59
|
}
|
|
57
|
-
this.functionWaiters.clear();
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
notify() {
|
|
62
64
|
if (this.count === 0 && this.zeroWaiters.length > 0) {
|
|
63
|
-
|
|
65
|
+
const zeroWaiters = this.zeroWaiters;
|
|
66
|
+
this.zeroWaiters = [];
|
|
67
|
+
for (const resolve of zeroWaiters) {
|
|
64
68
|
resolve(0);
|
|
65
69
|
}
|
|
66
|
-
this.zeroWaiters = [];
|
|
67
70
|
}
|
|
68
71
|
if (this.functionWaiters.size > 0) {
|
|
69
72
|
const ready = [];
|