Skip to content

Instantly share code, notes, and snippets.

Last active Dec 19, 2020
What would you like to do?
export function createDeferred<V> (): Deferred<V> {
let deferred: Deferred<V> = {} as any;
deferred.promise = new Promise((resolve, reject) => (
Object.assign(deferred, { resolve, reject })
return deferred;
export interface Deferred<V> {
promise: Promise<V>,
resolve (value: V | PromiseLike<V>): void,
reject (reason?: any): void,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment