parent
b276fc9cba
commit
fe9b6b5041
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
export type toPromiseCallback<T> = (err: Error | null, res?: T) => void;
|
||||||
|
export async function toPromise<T>(func: (cb: toPromiseCallback<T>) => void): Promise<T> {
|
||||||
|
return new Promise<T>((resolve, reject) => {
|
||||||
|
func((err, res) => err ? reject(err) : resolve(res));
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in new issue