jasnell / proposal-istypes

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

Opinion against certain functions #17

Closed Ginden closed 7 years ago

Ginden commented 7 years ago

I feel like checks like:

shouldn't be included in language. Using any of them feels like a code smell for me - these classes doesn't have any meaningful internals. There is no actual difference between any iterator and StringIterator. And

In case of isGeneratorFunction it's merely syntax-level distinction - there is no difference between generator and function returning object with the same interface.

ljharb commented 7 years ago

If we're going to add brand checking methods, then everything needs to be brand checkable.

Since the iterators are distinct objects, there needs to be a cross-realm way to distinguish them.

Ginden commented 7 years ago

For me it's encouraging to implement bad practices (because distinction generator/non-generator is merely implementation detail of function) and language shouldn't encourage end users to make such bad.

ljharb commented 7 years ago

You can already distinguish those things (https://www.npmjs.com/package/is-generator-function) - this just provides a consistent way to do so.

jasnell commented 7 years ago

I have reworked the proposal significantly to move away from the Is{Type} pattern and use a more extensible mechanism that aligns well with the existing typeof and Object.is() patterns. Please take a look at the updated proposal in this repositories readme.