Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setTimeout() not available in mujs

Help, I'm trying to setup my environment to do a Hello World.

 1 #!/usr/bin/env mujs                                                             
 2                                                                                 
 3 console.log("Hello!");                                                          
 4 setTimeout(console.log, 2000);  // 2s

$ nano lqlq.js && ./lqlq.js 
Hello!
ReferenceError: 'setTimeout' is not defined
        at ./lqlq.js:4

That particular interpreter prides itself in being standard-compliant

There are no non-standard extensions
source

but I can't see how a basic sleep() can be non-standard.

extra/mujs 1.3.5-1 [installed]
    An embeddable Javascript interpreter in C

$ uname -r
6.10.4-arch2-1
like image 581
Vorac Avatar asked Nov 17 '25 17:11

Vorac


1 Answers

setTimeout() is part of NodeJS. In order to use it, node's interpreter is needed.

#!/usr/bin/env node
like image 125
Vorac Avatar answered Nov 20 '25 07:11

Vorac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!