API Documentation
    Preparing search index...

    Function async

    • Runs given callback async.

      Type Parameters

      • Args extends any[]
      • Result

      Parameters

      • callback: (...args: Args) => Result | PromiseLike<Result>

        a function to execute async

      • delay: number

        the delay in msec

      • ...args: Args

        the arguments pushed to the callback during execution.

      Returns CancelablePromise<Result>

      the execution promise

      import async from "apprt-core/async";
      // a sum function
      const sum = (x: number, y: number) => x + y;
      // execute 3 + 4, 200msec later
      const result = await async(sum, 200, 3, 4);
      // result === 7
      assert.equal(result, 7);
    • Same as the first overload, but without a delay.

      Type Parameters

      • Args extends any[]
      • Result

      Parameters

      Returns CancelablePromise<Result>