export function create < T > ( id ) { let localResolve = ( ) => { } ; let localReject = ( ) => { } ; const promise = new Promise ( ( resolve , reject ) => { localResolve = resolve ; localReject = reject ; } ) ; return { id , resolve : localResolve , reject : localReject , promise , } ; } export interface Deferred < T > { id : number | string ; promise : Promise < T > ; resolve : ( t : T ) => void ; reject : ( e : Error ) => void ; }