Skip to content

Timeout

Executes the given callback function within a specified time limit (in milliseconds).

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

Parameters

() => void fn
    The callback function to execute.

number milliseconds
    The maximum time (in milliseconds) to execute the callback function.

Returns

The result of the callback function if it completes within the specified time limit; otherwise, null.

Remarks

If the function completes within the given time limit, the function returns the callback result. Otherwise, it returns null.

Example

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