You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mutual Exclusiveness 🔒: Ensures the mutually exclusive execution of asynchronous tasks, either to prevent potential race conditions caused by tasks spanning across multiple event-loop iterations, or for performance optimization.
Graceful Termination ⏳: Await the completion of all currently pending and executing tasks using the waitForAllExistingTasksToComplete method. Example use cases include application shutdowns (e.g., onModuleDestroy in Nest.js applications) or maintaining a clear state between unit-tests.
Suitable for "check and abort" scenarios: The isAvailable getter indicator enables to skip or abort operations if the lock is currently held by another task.
High Efficiency ⚙️: Leverages the Node.js microtasks queue to serve tasks in FIFO order, eliminating the need for manually managing an explicit queue of pending tasks.
Comprehensive documentation 📚: The class is thoroughly documented, enabling IDEs to provide helpful tooltips that enhance the coding experience.
Tests 🧪: Fully covered by extensive unit tests.
No external runtime dependencies: Only development dependencies are used.
ES2020 Compatibility: The tsconfig target is set to ES2020.