UNPKG

dd-trace

Version:

Datadog APM tracing client for JavaScript

31 lines (21 loc) 504 B
'use strict' class Scheduler { _timer = null constructor (callback, interval) { this._callback = callback this._interval = interval } start () { if (this._timer) return this.runAfterDelay(0) } runAfterDelay (interval = this._interval) { this._timer = setTimeout(this._callback, interval, () => this.runAfterDelay()) this._timer.unref && this._timer.unref() } stop () { clearTimeout(this._timer) this._timer = null } } module.exports = Scheduler