Interface Timeout
_onTimeout(...args: any[]): void;
"[dispose]"(): void;
"[toPrimitive]"(): number;
close(): this;
hasRef(): boolean;
ref(): this;
refresh(): this;
unref(): this;
}
Hierarchy (View Summary)
- RefCounted
- Disposable
- Timer
- Timeout
Index
Methods
_onTimeout
Parameters
- ...args: any[]
Returns void
[dispose]
[toPrimitive]
Coerce a
Timeoutto a primitive. The primitive can be used to clear theTimeout. The primitive can only be used in the same thread where the timeout was created. Therefore, to use it acrossworker_threadsit must first be passed to the correct thread. This allows enhanced compatibility with browsersetTimeout()andsetInterval()implementations.Returns number
close
hasRef
ref
When called, requests that the Node.js event loop not exit so long as the
Timeoutis active. Callingtimeout.ref()multiple times will have no effect.By default, all
Timeoutobjects are "ref'ed", making it normally unnecessary to calltimeout.ref()unlesstimeout.unref()had been called previously.Returns this
a reference to
timeout
refresh
Sets the timer's start time to the current time, and reschedules the timer to call its callback at the previously specified duration adjusted to the current time. This is useful for refreshing a timer without allocating a new JavaScript object.
Using this on a timer that has already called its callback will reactivate the timer.
Returns this
a reference to
timeout
unref
When called, the active
Timeoutobject will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before theTimeoutobject's callback is invoked. Callingtimeout.unref()multiple times will have no effect.Returns this
a reference to
timeout
This object is created internally and is returned from
setTimeout()andsetInterval(). It can be passed to eitherclearTimeout()orclearInterval()in order to cancel the scheduled actions.By default, when a timer is scheduled using either
setTimeout()orsetInterval(), the Node.js event loop will continue running as long as the timer is active. Each of theTimeoutobjects returned by these functions export bothtimeout.ref()andtimeout.unref()functions that can be used to control this default behavior.