MCPcopy Create free account
hub / github.com/coopernurse/node-pool / setTimeout

Method setTimeout

lib/ResourceRequest.js:32–52  ·  view source on GitHub ↗
(delay)

Source from the content-addressed store, hash-verified

30 }
31
32 setTimeout(delay) {
33 if (this._state !== ResourceRequest.PENDING) {
34 return;
35 }
36 const ttl = parseInt(delay, 10);
37
38 if (isNaN(ttl) || ttl <= 0) {
39 throw new Error("delay must be a positive int");
40 }
41
42 const age = Date.now() - this._creationTimestamp;
43
44 if (this._timeout) {
45 this.removeTimeout();
46 }
47
48 this._timeout = setTimeout(
49 fbind(this._fireTimeout, this),
50 Math.max(ttl - age, 0)
51 );
52 }
53
54 removeTimeout() {
55 if (this._timeout) {

Callers 1

constructorMethod · 0.95

Calls 3

removeTimeoutMethod · 0.95
fbindFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected