spion/blue-tape

`instanceof Function` isn't reliable cross-realm

ljharb opened this issue · 3 comments

If you have a promise from an iframe or a worker or something, Function is different, and instanceof won't work.

A simple test is typeof foo === 'function', but https://www.npmjs.com/package/is-callable is a fully reliable test that works across all engines. Would you accept a PR using that?

Oh dear, did I really write that? :D D'oh!

Yes, I'd definitely accept a PR that replaces it with typeof foo === 'function'. When does is-callable do better than a typeof test?

There's some older engines where typeof /a/g === 'function', primarily.