jasnell / proposal-istypes

TC-39 Proposal for additional is{Type} APIs
201 stars 7 forks source link

Object.isGeneratorObject #10

Closed rwaldron closed 7 years ago

rwaldron commented 7 years ago

This leads to the obvious question: should Generator be exposed globally? https://tc39.github.io/ecma262/#sec-generator-objects

(I'm not saying it should, I'm just opening this for discussion)

zloirock commented 7 years ago

Also, GeneratorFunction - now it causes problems for polyfilling.

Jamesernator commented 7 years ago

Also AsyncFunction (and eventually AsyncGeneratorFunction).

My personal feeling is they should be attached to the appropriate types even if the types aren't available. but they probably need a way to access them on Function as well.

jasnell commented 7 years ago

If at all possible, I would very much like to avoid exposing additional things that should not or cannot be used directly by users. Having Generator as an exposed type would inevitably lead to someone asking if new Generator() is possible, and if not, why not. If we can hang methods such as isGeneratorObject() and isGeneratorFunction() off something that already exists, even if it's not a completely ideal location, then I'd see that as being far more desirable.

rwaldron commented 7 years ago

@jasnell thanks for the response, I think that's a reasonable argument.