Function setSafeInterval

  • Wraps the callback for setInterval so errors get caught and logged. Parameters are identical to the setInterval parameters starting from the 3rd argument. The logger and message will be used when the callback throws an error. Supports asynchronous callback functions.

    Parameters

    • logger: Logger
    • message: string
    • callback: ((...cbArgs) => void)
        • (...cbArgs): void
        • Parameters

          • Rest ...cbArgs: any[]

          Returns void

    • Optional ms: number
    • Rest ...args: any[]

    Returns NodeJS.Timeout