mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-26 03:52:23 -08:00
cef64329a9
Some checks failed
Test Master / install-and-build (push) Has been cancelled
Benchmark Docker Image CI / build (push) Has been cancelled
Test Master / Unit tests (18.x) (push) Has been cancelled
Test Master / Unit tests (20.x) (push) Has been cancelled
Test Master / Unit tests (22.4) (push) Has been cancelled
Test Master / Lint (push) Has been cancelled
Test Master / Notify Slack on failure (push) Has been cancelled
18 lines
495 B
TypeScript
18 lines
495 B
TypeScript
type ResolveFn<T> = (result: T | PromiseLike<T>) => void;
|
|
type RejectFn = (error: Error) => void;
|
|
|
|
export interface IDeferredPromise<T> {
|
|
promise: Promise<T>;
|
|
resolve: ResolveFn<T>;
|
|
reject: RejectFn;
|
|
}
|
|
|
|
export function createDeferredPromise<T = void>(): IDeferredPromise<T> {
|
|
const deferred: Partial<IDeferredPromise<T>> = {};
|
|
deferred.promise = new Promise<T>((resolve, reject) => {
|
|
deferred.resolve = resolve;
|
|
deferred.reject = reject;
|
|
});
|
|
return deferred as IDeferredPromise<T>;
|
|
}
|