I am using node.js. I want to do something like the following:
if (execution of foo() takes at most 30s) {
var X = value returned by foo();
} else {
console.log('foo() took too long');
}
How can I do this?
I am using node.js. I want to do something like the following:
if (execution of foo() takes at most 30s) {
var X = value returned by foo();
} else {
console.log('foo() took too long');
}
How can I do this?
You can execute your function during 30 seconde in this line. Then it is cut down.
var X = setTimeOut(foo(){return 0}, 30000)
So you don't need information of timeout in console.log