Closed Ginden closed 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.
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.
You can already distinguish those things (https://www.npmjs.com/package/is-generator-function) - this just provides a consistent way to do so.
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.
I feel like checks like:
isSetIterator
isGeneratorFunction
isMapIterator
isGeneratorObject
isStringIterator
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
. AndIn case of
isGeneratorFunction
it's merely syntax-level distinction - there is no difference between generator and function returning object with the same interface.