@alwaysblank/denden
    Preparing search index...

    Function asPromise

    • Returns a version of func which returns a Promise rather than expecting a callback.

      Type Parameters

      • A

        The argument that will be passed to the callback.

      • F extends (callback: (a: A) => any, ...args: any[]) => any

        The type of func.

      Parameters

      • func: F

        Function that expects a callback as its first argument.

      Returns (...args: Parameters<OmitFirstArg<F>>) => Promise<A>

      const fn = (callback, a, b) => doSomething(callback, a, b);
      const promised = asPromise(fn);
      promised(1, 2).then(result => console.log(result));