std/node: Node compatible setTimeout, setInterval
See original GitHub issuesetTimeout in Node.js returns Timeout object
ref(Node.js):
- https://github.com/nodejs/node/blob/8ee4e672eca6826e7b6f2c1ad36ecbe6e570d412/lib/timers.js#L140
- https://github.com/nodejs/node/blob/ee9e2a2eb6143fa7b4b1454f7aed009a8703d4d7/lib/internal/timers.js#L167
We have Timeout
class implemented in std/node, but doesn’t seem implementing setTimeout correctly
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Scheduling: setTimeout and setInterval
setInterval allows us to run a function repeatedly, starting after the interval of time, then repeating continuously at that interval. These ...
Read more >Timers in Node JS (setTimeout, setImmediate, setInterval ...
Let's Explore the different timer methods and their use case. Supported Timers Methods. setTimeout; setImmediate; setInterval; process.nextTick ...
Read more >Timers in Node.js
Just like setTimeout() , setInterval() also returns a Timeout object which can be used to reference and modify the interval that was set....
Read more >TypeScript - use correct version of setTimeout (node vs window)
setTimeout which will break if you run the code on nodeJS server (eg. server-side rendered page). Good news, this is also compatible with...
Read more >setInterval() - Web APIs - MDN Web Docs
It may be helpful to be aware that setInterval() and setTimeout() share the same pool of IDs, and that clearInterval() and clearTimeout() ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d say it is probably safe to override them in compat mode, if
Symbo.toPrimitive
is implemented on the timers object. Very ugly though (and very painful). See responses to https://twitter.com/lcasdev/status/1462766579196862470Channeling @lucacasonato: idea is to monkey-patch setTimeout/setInterval globals and return objects instead of numbers in
--compat
mode.(My recollection was to return objects always but I might be misremembering and I don’t have a strong preference anyway.)