Skip to content

Instantly share code, notes, and snippets.

@sebastiankade
Created May 19, 2019 00:46
Show Gist options
  • Save sebastiankade/26f6b8263f005cb6259a11b55a81ec97 to your computer and use it in GitHub Desktop.
Save sebastiankade/26f6b8263f005cb6259a11b55a81ec97 to your computer and use it in GitHub Desktop.
Typescript wrapper for node util promisify
import * as util from "util";
type Maybe<T> = T | undefined | null;
export function promisify<Args, R>(
fn: (arg: Args, callback: (e: Maybe<Error>, result: R) => void) => void,
self?: any
): (arg: Args) => Promise<R> {
return util.promisify(fn).bind(self);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment