export default function use(promise: PromiseLike): T { const internal: PromiseLike & { status?: 'pending' | 'fulfilled' | 'rejected'; value?: T; reason?: any; } = promise; if (internal.status === 'fulfilled') { return internal.value; } if (internal.status === 'rejected') { throw internal.reason; } else if (internal.status === 'pending') { throw internal; } else { internal.status = 'pending'; internal.then( (result) => { internal.status = 'fulfilled'; internal.value = result; }, (reason) => { internal.status = 'rejected'; internal.reason = reason; }, ); throw internal; } }