// From: https://gist.github.com/compulim/8b49b0a744a3eeb2205e2b9506201e50 export interface IDeferredPromise { promise: () => Promise; reject: (error: Error) => void; resolve: (result: T) => void; } export function createDeferredPromise(): Promise> { return new Promise>(resolveCreate => { const promise = new Promise((resolve, reject) => { resolveCreate({ promise: () => promise, resolve, reject }); }); }); }