Skip to content

Timeout

Executes the given callback function at maximum in the given milliseconds.

1
myScript.Timeout(fn: () => void, milliseconds: number):( `"null"` | object )

Parameters

() => void fn
    The callback to execute.

number milliseconds
    The maximum milliseconds to execute the callback.

Remarks

When function completed in the given milliseconds, the function returns the callback result, otherwise returns null.

Example

1
2
3
4
var result = Script.Timeout(function() {
  // Endless loop
  while(true) {};
}, 1000);