Variable MaybePromise

MaybePromise: {
    transform: {
        <T, R>(value: Promise<T>, transformer: ((value: T) => R)): Promise<R>;
        <T, R>(value: T, transformer: ((value: T) => R)): T extends Promise<any>
            ? Promise<R>
            : R;
    };
}

Type declaration

  • transform: {
        <T, R>(value: Promise<T>, transformer: ((value: T) => R)): Promise<R>;
        <T, R>(value: T, transformer: ((value: T) => R)): T extends Promise<any>
            ? Promise<R>
            : R;
    }
      • <T, R>(value, transformer): Promise<R>
      • Transforms the value within the promise.

        Type Parameters

        • T
        • R

        Parameters

        • value: Promise<T>
        • transformer: ((value: T) => R)
            • (value): R
            • Parameters

              • value: T

              Returns R

        Returns Promise<R>

        a new promise with the transformed result.

      • <T, R>(value, transformer): T extends Promise<any>
            ? Promise<R>
            : R
      • Transforms the value, or if the value is a promise, transform the resolved value of the promise.

        Type Parameters

        • T
        • R

        Parameters

        • value: T
        • transformer: ((value: T) => R)
            • (value): R
            • Parameters

              • value: T

              Returns R

        Returns T extends Promise<any>
            ? Promise<R>
            : R

        the transformed result, or if the value is a promise, a new promse with the transformed result.