You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the way Array.from works. It takes any iterable and casts it to array.
As discussed in #317 - we have to deprecate toMap, toList, and etc. methods, but we also need a good replacement for it.
We can do this in constructors - but immutable class constructors returns values in it, which is restricted in es6 classes spec and sooner or later people will start to demand untranspiled ES6 module version for modern browsers.
And as a summary:
Implement #from(iterable) for each method.
Add deprecation warnings for toCollection methods.
The text was updated successfully, but these errors were encountered:
Is there an example of a collection that does not already accept an iterable in this way? If I recall, Array.from was added because new Array() takes arguments in a weird way and changing that would have broken the internet so TC39 just added a new method instead. Contrast that with ES6 Map and Set which do not have .from() methods, but who's constructor functions have the same contract of accepting an iterable.
Yeah you're right, I was thinking about replacement for toCollection and problem with constructors in ES6 and came up with this idea.
Anyways, thanks for quick response, I would love to work on this direction.
Main idea I was thinking about is - optimization for better tree shaking and circular deps with static methods are main issues.
I like the way Array.from works. It takes any iterable and casts it to array.
As discussed in #317 - we have to deprecate
toMap
,toList
, and etc. methods, but we also need a good replacement for it.We can do this in constructors - but immutable class constructors returns values in it, which is restricted in es6 classes spec and sooner or later people will start to demand untranspiled ES6 module version for modern browsers.
And as a summary:
#from(iterable)
for each method.toCollection
methods.The text was updated successfully, but these errors were encountered: