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

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton