3 ms·
> Or, really, part of standard js, maybe.see: It's a part of node, at least: https://nodejs.org/docs/latest-v12.x/api/util.html#util_util_types_ispromise_value
by mikewhy 6y ago
> Or, really, part of standard js, maybe.see:
It's a part of node, at least: https://nodejs.org/docs/latest-v12.x/api/util.html#util_util_types_ispromise_value https://nodejs.org/docs/latest-v12.x/api/util.html#util_util...
- staticassertion 6y agoThis will work for a standard Promise, which is great, but not for weirdo made up promises. It also was released, I think, in 2018. It's one thing if you own the entire codebase, but if you're building a popular, multiple-years-old library/framework, you can't make the same assumptions.
- mikewhy 6y agoI'm only finding about it today TBH. Usually I go for what this library does: function isPromise(obj) { return typeof obj?.then === 'function' }