sindresorhus / promise-fun

Promise packages, patterns, chat, and tutorials

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to access the state of a promise synchronously?

fregante opened this issue · comments

Officially there's no way to check whether a promise has resolved without awaiting it. Is there a module for this already?

Like a synchronous reflect: https://github.com/sindresorhus/p-reflect

const promise = new OpenPromise(resolve => setTimeout(resolve, Math.random() * 100000));

await delay(1000);
if (promise.isFulfilled) {
	console.log('Hurray!')
}