Last active
March 18, 2025 20:25
-
-
Save legomushroom/e9c02c864a42bf5a8a0f91d2e0590dba to your computer and use it in GitHub Desktop.
Get Promise state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice one Oleg!