Skip to content

Commit 46d383d

Browse files
authored
Update README.md - setTimeout()/setInterval() (#643)
* Update README.md - setTimeout()/setInterval() Brings more context about the implementation of setTimeout/setInterval - and why a JS engine cannot provide their implementation.
1 parent 79f3a7e commit 46d383d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ No. An instance of goja.Runtime can only be used by a single goroutine
102102
at a time. You can create as many instances of Runtime as you like but
103103
it's not possible to pass object values between runtimes.
104104

105-
### Where is setTimeout()?
105+
### Where is setTimeout()/setInterval()?
106+
107+
setTimeout() and setInterval() are common functions to provide concurrent execution in ECMAScript environments, but the two functions are not part of the ECMAScript standard.
108+
Browsers and NodeJS just happen to provide similar, but not identical, functions. The hosting application need to control the environment for concurrent execution, e.g. an event loop, and supply the functionality to script code.
106109

107-
setTimeout() assumes concurrent execution of code which requires an execution
108-
environment, for example an event loop similar to nodejs or a browser.
109110
There is a [separate project](https://github.com/dop251/goja_nodejs) aimed at providing some NodeJS functionality,
110111
and it includes an event loop.
111112

0 commit comments

Comments
 (0)