Skip to content

Commit

Permalink
Allow chaining refresh(), ref(), and unref()
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Sep 10, 2024
1 parent 7e3d34f commit a9faed2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,31 @@ class Timer {
}

refresh () {
if (this._list === null) return
if (this._list === null) return this
this._list.clear(this)
this._expiry = Date.now() + this._list.ms
this._list.push(this)

maybeUpdateTimer()
return this
}

hasRef () {
return this._refed
}

unref () {
if (this._refed === false) return
if (this._refed === false) return this
this._refed = false
decRef()
return this
}

ref () {
if (this._refed === true) return
if (this._refed === true) return this
this._refed = true
incRef()
return this
}
}

Expand Down

0 comments on commit a9faed2

Please sign in to comment.