Comment Comment by adrianhel There should be a Promise.isThenable or Promise.is. Strictly speaking this library checks if a value is a thenable.With optional chaining I would however use this check: typeof x?.then === 'function' Or if I was code golfin: x?.then?.call The first case does not account for built in prototype extensions and the second has false positives with certain data structures.So the function in is-promise should be available as Promise.isThenable or Promise.is. parent adrianhel 6 years ago
With optional chaining I would however use this check:
Or if I was code golfin: The first case does not account for built in prototype extensions and the second has false positives with certain data structures.So the function in is-promise should be available as Promise.isThenable or Promise.is.