@kayahr/assert
    Preparing search index...

    Function assertTimeout

    Asserts that given function does not take longer than the given number of milliseconds. When function is asynchronous then execution is immediately aborted when timeout is reached. When function is synchronous then it is not possible to abort execution after reaching the timeout but an exception is thrown as soon as the synchronous function returns.

    The maximum time (in milliseconds) the function is allowed to run.

    The function to run (can be synchronous or asynchronous).

    Optional reason added to exception message when assertion fails.

    AssertionError when function execution took longer than allowed.

    • Type Parameters

      • T

      Parameters

      • milliseconds: number
      • func: () => Promise<T>
      • Optionalreason: string

      Returns Promise<T>

    • Type Parameters

      • T

      Parameters

      • milliseconds: number
      • func: () => T
      • Optionalreason: string

      Returns T