@mikeyt23/node-cli-utils
    Preparing search index...

    Function conditionallyAsync

    • Executes an asynchronous function conditionally.

      Type Parameters

      • T

        The type of value that the asyncFunc returns.

      Parameters

      • condition: boolean

        A boolean that determines if the asyncFunc should be executed.

      • asyncFunc: AsyncFunc<T>

        The async function to execute if the condition is true.

      • OptionallogEnabled: boolean

        Optional. Determines whether to enable logging. Defaults to false.

      Returns Promise<T | undefined>

      Returns a Promise resolving to the value returned by asyncFunc if the condition is true, otherwise returns undefined.

    • Executes an asynchronous function conditionally.

      Type Parameters

      • T

        The type of value that the asyncFunc returns.

      Parameters

      • conditionAsyncFunc: AsyncBooleanFunc

        An async function that returns a boolean that determines whether asyncFunc should be executed.

      • asyncFunc: AsyncFunc<T>

        The async function to execute if the condition is true.

      • OptionallogEnabled: boolean

        Optional. Determines whether to enable logging. Defaults to false.

      Returns Promise<T | undefined>

      Returns a Promise resolving to the value returned by asyncFunc if the condition is true, otherwise returns undefined.