mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 09:34:07 -08:00
15 lines
476 B
TypeScript
15 lines
476 B
TypeScript
|
// From: https://gist.github.com/compulim/8b49b0a744a3eeb2205e2b9506201e50
|
||
|
export interface IDeferredPromise<T> {
|
||
|
promise: () => Promise<T>;
|
||
|
reject: (error: Error) => void;
|
||
|
resolve: (result: T) => void;
|
||
|
}
|
||
|
|
||
|
export function createDeferredPromise<T>(): Promise<IDeferredPromise<T>> {
|
||
|
return new Promise<IDeferredPromise<T>>(resolveCreate => {
|
||
|
const promise = new Promise<T>((resolve, reject) => {
|
||
|
resolveCreate({ promise: () => promise, resolve, reject });
|
||
|
});
|
||
|
});
|
||
|
}
|