Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Promise state
export const promiseState = async (p: Promise<any>): Promise<string> => {
const t = {};
return await Promise.race([p, t]).then(
(v) => {
return (v === t)
? 'pending'
: 'fulfilled';
},
() => 'rejected');
};
ff
f
f
f
f
f
@lostintangent

This comment has been minimized.

Copy link

lostintangent commented Dec 4, 2019

Nice one Oleg!

@legomushroom

This comment has been minimized.

Copy link
Owner Author

legomushroom commented Dec 6, 2019

Thank you, sir! ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.