-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array.prototype.find() returns -1 instead of undefined #178
Comments
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 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 |
- Make instrumentation robust against montagejs/collections#178. - Make check for disabled instrumentation stricter (the keys provided in config.tracing.disabledTracers/INSTANA_DISABLED_TRACERS need to be an exact, case-insensitive match of the instrumentation file now). If you have used this configuration option and relied on the fact that this was a string.contains check previously, you might need to update your config.
- Make instrumentation robust against montagejs/collections#178. - Make check for disabled instrumentation stricter (the keys provided in config.tracing.disabledTracers/INSTANA_DISABLED_TRACERS need to be an exact, case-insensitive match of the instrumentation file now). If you have used this configuration option and relied on the fact that this was a string.contains check previously, you might need to update your config.
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.
The text was updated successfully, but these errors were encountered: