We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac65928 commit d1c314cCopy full SHA for d1c314c
src/Mutex.js
@@ -9,10 +9,10 @@ module.exports = class Mutex {
9
this._store = new idb.Store(this._database + "_lock", this._database + "_lock")
10
this._lock = null
11
}
12
- async has () {
+ async has ({ margin = 2000 } = {}) {
13
if (this._lock && this._lock.holder === this._id) {
14
const now = Date.now()
15
- if (this._lock.expires > now) {
+ if (this._lock.expires > now + margin) {
16
return true
17
} else {
18
return await this.renew()
0 commit comments