@chickenjdk/byteutils
    Preparing search index...

    Function maybePromiseThen

    • A function to help with processing values that may or may not be promises

      Type Parameters

      • maybePromise extends unknown

        The value that may or may not be a promise

      • returnType

      Parameters

      • maybePromise: maybePromise
      • callback: (
            value: maybePromise extends PromiseLike<unknown>
                ? Awaited<maybePromise>
                : maybePromise,
        ) => returnType

        The callback to call with the value returned when the promise is resolved or when the value is returned directly.

      Returns maybePromise extends PromiseLike<unknown> ? Promise<returnType> : returnType

      Whet the callback returns, if the input is a promise, it will return a promise that resolves to the value returned by the callback. If the input is not a promise, it will return the value returned by the callback directly.