Skip to content

disposable-lock@2.0.0

Choose a tag to compare

@juner juner released this 17 Nov 01:05
· 37 commits to main since this release

View on npm

Highlights

  • Updated the request() API to return null when a lock cannot be acquired (e.g., ifAvailable: true), replacing the previous NotHaveLock object.
  • Ensures compatibility with await using / AsyncDisposable patterns.
  • TypeScript types updated to reflect Promise<ReleasableLock | null> return type.

Changes

Changed

  • lock(name).request() now returns Promise<ReleasableLock | null> instead of Promise<ReleasableLock | NotHaveLock>.
  • Explicit lock acquisition failure is now represented as null, making if (lock) checks safe and intuitive.
  • Simplified README examples to reflect null handling and AsyncDisposable usage.

Fixed

  • await using works safely even if the lock could not be acquired.

References