MCPcopy
hub / github.com/bee-queue/bee-queue / schedule

Method schedule

lib/eager-timer.js:25–46  ·  view source on GitHub ↗
(time)

Source from the content-addressed store, hash-verified

23 }
24
25 schedule(time) {
26 if (this._stopped) return;
27
28 const now = Date.now();
29
30 if (time < 0 || time == null || isNaN(time)) {
31 // Times earlier than 0 signify maximum delay.
32 time = now + this._maxDelay;
33 } else if (time <= now) {
34 // If it's in the past, trigger immediately, and reschedule to max delay.
35 this._schedule(now + this._maxDelay);
36 return this.emit('trigger');
37 } else {
38 // Don't try to schedule past the maximum delay.
39 time = Math.min(time, now + this._maxDelay);
40 }
41
42 // Only overwrite the existing timer if later than the given time.
43 if (!this._timer || time < this._nextTime) {
44 this._schedule(time);
45 }
46 }
47
48 stop() {
49 this._stop();

Callers 4

_saveMethod · 0.80
_onMessageMethod · 0.80
_activateDelayedMethod · 0.80

Calls 1

_scheduleMethod · 0.95

Tested by

no test coverage detected