FuncType - v0.8.64
    Preparing search index...

    Function Task

    • Task adapter for bridging promise-based code with functional error handling patterns

      Type Parameters

      • T = unknown

      Parameters

      Returns {
          _tag: string;
          _type: string;
          Async: <U = T>(
              t: () => U | Promise<U>,
              e?: (error: unknown) => unknown,
              f?: () => void | Promise<void>,
          ) => FPromise<U>;
          fail: (error: unknown) => TaskException<T>;
          fromPromise: <U, Args extends unknown[]>(
              promiseFn: (...args: Args) => Promise<U>,
          ) => (...args: Args) => FPromise<U>;
          success: (data: T) => TaskResult<T>;
          Sync: <U = T>(
              t: () => U,
              e?: (error: unknown) => unknown,
              f?: () => void,
          ) => Sync<U>;
          toPromise: <U>(taskResult: TaskResult<U> | TaskException<U>) => Promise<U>;
          toString(): string;
      }

      • Readonly_tag: string
      • _type: string
      • Async: <U = T>(
            t: () => U | Promise<U>,
            e?: (error: unknown) => unknown,
            f?: () => void | Promise<void>,
        ) => FPromise<U>

        Run an async operation with explicit try/catch/finally semantics Returns a raw Promise that can interact with traditional Promise-based code

      • fail: (error: unknown) => TaskException<T>

        Create a failed Task result

      • fromPromise: <U, Args extends unknown[]>(
            promiseFn: (...args: Args) => Promise<U>,
        ) => (...args: Args) => FPromise<U>

        Convert a Promise-returning function to a Task-compatible function

      • success: (data: T) => TaskResult<T>

        Create a successful Task result

      • Sync: <U = T>(t: () => U, e?: (error: unknown) => unknown, f?: () => void) => Sync<U>

        Run a synchronous operation with explicit try/catch/finally semantics Returns an Either for functional error handling

      • toPromise: <U>(taskResult: TaskResult<U> | TaskException<U>) => Promise<U>

        Convert a Task result to a Promise

      • toString: function
        • Returns string