Skip to content

Commit

Permalink
idempotent promise
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Sep 27, 2024
1 parent 57d2c01 commit e4dc664
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ module.exports = class CoreStorage {

_waitForIdle () {
if (this.isIdle()) return Promise.resolve()
return new Promise((resolve) => { this._onidle = resolve })
if (!this._onidlePromise) {
this._onidlePromise = new Promise((resolve) => { this._onidle = resolve })
}

return this._onidlePromise
}

async idle () {
Expand Down

0 comments on commit e4dc664

Please sign in to comment.