MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/timers.js:179–221  ·  view source on GitHub ↗
(callback, after, args, isRepeat, isRefed)

Source from the content-addressed store, hash-verified

177 // Timer constructor function.
178 // The entire prototype is defined in lib/timers.js
179 constructor(callback, after, args, isRepeat, isRefed) {
180 if (after === undefined) {
181 after = 1;
182 } else {
183 after *= 1; // Coalesce to number or NaN
184 }
185
186 if (!(after >= 1 && after <= TIMEOUT_MAX)) {
187 if (after > TIMEOUT_MAX) {
188 process.emitWarning(`${after} does not fit into` +
189 ' a 32-bit signed integer.' +
190 '\nTimeout duration was set to 1.',
191 'TimeoutOverflowWarning');
192 } else if (after < 0 && !warnedNegativeNumber) {
193 warnedNegativeNumber = true;
194 process.emitWarning(`${after} is a negative number.` +
195 '\nTimeout duration was set to 1.',
196 'TimeoutNegativeWarning');
197 } else if (NumberIsNaN(after) && !warnedNotNumber) {
198 warnedNotNumber = true;
199 process.emitWarning(`${after} is not a number.` +
200 '\nTimeout duration was set to 1.',
201 'TimeoutNaNWarning');
202 }
203 after = 1; // Schedule on next tick, follows browser behavior
204 }
205
206 this._idleTimeout = after;
207 this._idlePrev = this;
208 this._idleNext = this;
209 this._idleStart = null;
210 this._onTimeout = callback;
211 this._timerArgs = args;
212 this._repeat = isRepeat ? after : null;
213 this._destroyed = false;
214
215 if (isRefed)
216 incRefCount();
217 this[kRefed] = isRefed;
218 this[kHasPrimitive] = false;
219
220 initAsyncResource(this, 'Timeout');
221 }
222
223 // Make sure the linked list only shows the minimal necessary information.
224 [inspect.custom](_, options) {

Callers

nothing calls this directly

Calls 2

incRefCountFunction · 0.85
initAsyncResourceFunction · 0.85

Tested by

no test coverage detected