@vgerbot/async
    Preparing search index...

    Function asyncify

    • Wraps a synchronous function to return a cancellable promise. Converts any function into an async operation.

      Type Parameters

      • T

        The return type of the function

      • Args extends unknown[] = unknown[]

      Parameters

      • fn: (...args: Args) => T

        The synchronous function to wrap

      • Optionaloptions: CancellableOptions<T>

        Cancellable configuration options

      Returns (...args: Args) => CancellableHandle<T>

      A function that returns a cancellable handle

      const syncFn = (x: number) => x * 2;
      const asyncFn = asyncify(syncFn);
      const result = await asyncFn(5); // 10