export interface IDeferredPromise < T > { promise : ( ) => Promise < T > ; reject : ( error : Error ) => void ; resolve : ( result : T ) => void ; } export async function createDeferredPromise < T > ( ) { return new Promise < IDeferredPromise < T > > ( ( resolveCreate ) => { const promise = new Promise < T > ( ( resolve , reject ) => { resolveCreate ( { promise : async ( ) => promise , resolve , reject } ) ; } ) ; } ) ; }