FuncType - v0.8.85
    Preparing search index...

    Variable TaskConst

    Task: <T = unknown>(
        params?: TaskParams,
    ) => {
        _tag: string;
        _type: string;
        Async: <U = T>(
            t: () => U | Promise<U>,
            e?: (error: unknown) => unknown,
            f?: () => void | Promise<void>,
            cancellationToken?: CancellationToken,
        ) => FPromise<U>;
        AsyncWithProgress: <U = T>(
            t: (updateProgress: (percent: number) => void) => U | Promise<U>,
            onProgress: (percent: number) => void,
            e?: (error: unknown) => unknown,
            f?: () => void | Promise<void>,
            cancellationToken?: CancellationToken,
        ) => FPromise<U>;
        Sync: <U = T>(
            t: () => U,
            e?: (error: unknown) => unknown,
            f?: () => void,
        ) => Sync<U>;
        toString(): string;
    } & {
        cancellable: <T>(
            task: (token: CancellationToken) => Promise<T>,
            params?: TaskParams,
        ) => { cancel: () => void; task: FPromise<T> };
        createCancellationTokenSource: () => CancellationTokenSource;
        fail: <T>(
            error: unknown,
            data?: unknown,
            params?: TaskParams,
        ) => TaskException<T>;
        formatErrorChain: (
            error: undefined | Error,
            options?: {
                includeStackTrace?: boolean;
                includeTasks?: boolean;
                separator?: string;
            },
        ) => string;
        fromNodeCallback: <T, Args extends unknown[]>(
            nodeFn: (
                ...args: [...Args[], (error: unknown, result: T) => void],
            ) => void,
            params?: TaskParams,
        ) => (...args: Args) => FPromise<T>;
        fromPromise: <U, Args extends unknown[]>(
            promiseFn: (...args: Args) => Promise<U>,
            params?: TaskParams,
        ) => (...args: Args) => FPromise<U>;
        getErrorChain: (error: undefined | Error) => Error[];
        race: <T>(
            tasks: FPromise<T>[],
            timeoutMs?: number,
            params?: TaskParams,
        ) => FPromise<T>;
        success: <T>(data: T, params?: TaskParams) => TaskResult<T>;
        toPromise: <U>(taskResult: TaskResult<U> | TaskException<U>) => Promise<U>;
        withProgress: <T>(
            task: (
                updateProgress: (percent: number) => void,
                token: CancellationToken,
            ) => Promise<T>,
            onProgress?: (percent: number) => void,
            params?: TaskParams,
        ) => {
            cancel: () => void;
            currentProgress: () => number;
            task: FPromise<T>;
        };
    } = ...

    Type declaration

      • <T = unknown>(
            params?: TaskParams,
        ): {
            _tag: string;
            _type: string;
            Async: <U = T>(
                t: () => U | Promise<U>,
                e?: (error: unknown) => unknown,
                f?: () => void | Promise<void>,
                cancellationToken?: CancellationToken,
            ) => FPromise<U>;
            AsyncWithProgress: <U = T>(
                t: (updateProgress: (percent: number) => void) => U | Promise<U>,
                onProgress: (percent: number) => void,
                e?: (error: unknown) => unknown,
                f?: () => void | Promise<void>,
                cancellationToken?: CancellationToken,
            ) => FPromise<U>;
            Sync: <U = T>(
                t: () => U,
                e?: (error: unknown) => unknown,
                f?: () => void,
            ) => Sync<U>;
            toString(): string;
        }
      • 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>,
                cancellationToken?: CancellationToken,
            ) => FPromise<U>;
            AsyncWithProgress: <U = T>(
                t: (updateProgress: (percent: number) => void) => U | Promise<U>,
                onProgress: (percent: number) => void,
                e?: (error: unknown) => unknown,
                f?: () => void | Promise<void>,
                cancellationToken?: CancellationToken,
            ) => FPromise<U>;
            Sync: <U = T>(
                t: () => U,
                e?: (error: unknown) => unknown,
                f?: () => void,
            ) => Sync<U>;
            toString(): string;
        }

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

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

        • AsyncWithProgress: <U = T>(
              t: (updateProgress: (percent: number) => void) => U | Promise<U>,
              onProgress: (percent: number) => void,
              e?: (error: unknown) => unknown,
              f?: () => void | Promise<void>,
              cancellationToken?: CancellationToken,
          ) => FPromise<U>

          Run an async operation with progress tracking capabilities Returns a Promise and provides progress updates via callback

        • 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

        • toString: function
          • Returns string

    • cancellable: <T>(
          task: (token: CancellationToken) => Promise<T>,
          params?: TaskParams,
      ) => { cancel: () => void; task: FPromise<T> }

      Create a task that can be cancelled

    • createCancellationTokenSource: () => CancellationTokenSource

      Create a cancellation token source

      A cancellation token source that can be used to control task cancellation

    • fail: <T>(error: unknown, data?: unknown, params?: TaskParams) => TaskException<T>

      Create a failed Task result

    • formatErrorChain: (
          error: undefined | Error,
          options?: {
              includeStackTrace?: boolean;
              includeTasks?: boolean;
              separator?: string;
          },
      ) => string

      Format the error chain as a string with the option to include task details

    • fromNodeCallback: <T, Args extends unknown[]>(
          nodeFn: (
              ...args: [...Args[], (error: unknown, result: T) => void],
          ) => void,
          params?: TaskParams,
      ) => (...args: Args) => FPromise<T>

      Convert a Node.js style callback function to a Task-compatible function Node.js callbacks typically have the signature (error, result) => void

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

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

    • getErrorChain: (error: undefined | Error) => Error[]

      Extract the error chain from a Throwable error Returns an array of errors from outermost to innermost

    • race: <T>(
          tasks: FPromise<T>[],
          timeoutMs?: number,
          params?: TaskParams,
      ) => FPromise<T>

      Race multiple tasks and return the result of the first one to complete Optionally specify a timeout after which the race will fail

    • success: <T>(data: T, params?: TaskParams) => TaskResult<T>

      Create a successful Task result

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

      Convert a Task result to a Promise

    • withProgress: <T>(
          task: (
              updateProgress: (percent: number) => void,
              token: CancellationToken,
          ) => Promise<T>,
          onProgress?: (percent: number) => void,
          params?: TaskParams,
      ) => {
          cancel: () => void;
          currentProgress: () => number;
          task: FPromise<T>;
      }

      Creates a task with progress tracking