time-queues 1.2.1 → 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 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,14 +61,15 @@ This project is licensed under the BSD-3-Clause License.
62
61
 
63
62
  ## Release History
64
63
 
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.*
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "time-queues",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Time queues to organize multitasking and scheduled tasks.",
5
5
  "type": "module",
6
6
  "types": "./src/index.d.ts",
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
- for (const resolve of this.zeroWaiters) {
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
- for (const {resolve} of this.functionWaiters) {
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
- for (const resolve of this.zeroWaiters) {
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 = [];