@pleisto/active-support
    Preparing search index...

    Variable guardConst

    guard: <TFunction extends () => any>(
        func: TFunction,
        shouldGuard?: (err: any) => boolean,
    ) => ReturnType<TFunction> extends Promise<any>
        ? Promise<Awaited<ReturnType<TFunction>> | undefined>
        : ReturnType<TFunction> | undefined

    A helper to try an async function that returns undefined if it fails.

    e.g. const result = await guard(fetchUsers)() ?? [];

    Type declaration

      • <TFunction extends () => any>(
            func: TFunction,
            shouldGuard?: (err: any) => boolean,
        ): ReturnType<TFunction> extends Promise<any>
            ? Promise<Awaited<ReturnType<TFunction>> | undefined>
            : ReturnType<TFunction> | undefined
      • Type Parameters

        • TFunction extends () => any

        Parameters

        • func: TFunction
        • OptionalshouldGuard: (err: any) => boolean

        Returns ReturnType<TFunction> extends Promise<any>
            ? Promise<Awaited<ReturnType<TFunction>> | undefined>
            : ReturnType<TFunction> | undefined