Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "promisify"

Index

Functions

Functions

Const promisify

  • promisify<T>(fn: Fn<Fn2<any, T, void>, void>): Promise<T>
  • Takes a function accepting a NodeJS-like callback w/ (error, result) args and converts it into a Promise, e.g. for use in async contexts.

    remarks

    The constructed promise calls the given function with a custom callback, which then either resolves or rejects the promise.

    example
    (async () => {
       const body = await promisify(partial(fs.readFile, "foo.txt"));
       console.log(body.toString());
    })();

    Type parameters

    • T

    Parameters

    • fn: Fn<Fn2<any, T, void>, void>

      function accepting a callback

    Returns Promise<T>

Generated using TypeDoc