Closed theetrain closed 6 years ago
I wrote Collections before the ink dried on the spec. Versions 1 and 3+ seem to be stuck with my mistake. @asolove and I fixed it in version 2.
This comes up often enough that @Stuk and I are considering forking collections and making an @collections/
org in npm rooted on version 2. That involves a lot of work and it is not on my evening and weekend roadmap. If there are people interested in sinking effort in that project, let us know. It would be great to have a community around such a central concern.
Collections is a Montage project so compatibility with Montage and all its inertia are the primary concern that dictates that Collections never stray far from backward compatibility with a host of API mispredictions.
why not, not modify native Array.prototype. This destroys any optimisations JS can do. Rather, create a new class based off Array.
@kennethklee as mentioned, Version 2 does not monkey-patch Array.prototype at all.
Alright, this has become enough of a problem that we will need broader support for collections in general. Please drop a line in here if you’ve got cycles to help move collections for JavaScript into a community supported suite to get around Montage’s compatibility limitations. We can talk about breaking the collections package into an @collections
organization and how we can build a group of maintainers to make that migration.
The default behaviour of
Array.prototype.find
is to return the first matching value orundefined
if not found. Collections.js returns-1
instead ofundefined
, which causes an unexpected issue with truthiness and coercion:Standard behaviour:
Collections.js behaviour:
I'm only curious why this decision was made.