-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make _.each break when false is returned #1545
Conversation
As far as the change is concerned, I don't have a strong opinion either way. However, it will badly break backwards compatibility so we should wait until a major version change regardless. |
Out of the changes I've made in my own implementation, I've noticed some devs stumble over exiting early in |
What about exposing |
In the past similar issues have been closed with recommendations to use |
It seems |
For the historically inclined, Underscore used to expose the breaker as
|
I'm in favor of exposing a generic sentinel value, perhaps with a more generic name like |
As I mentioned above returning
That seems unnecessarily complex. jQuery cleared the way for returning |
@jdalton Well, part of my desire for a non- The other part is that I can see a standard sentinel value being useful for contrib and other mixin suites. Though obviously contrib can create it's own sentinel if Underscore decides not to. Some previous discussion: documentcloud/underscore-contrib#20 |
Absolutely. Although in my experience devs tend to prefer CoffeeScript's iterator sugar to the Underscore helper methods so that may not be as big of a dealbreaker.
Also agreed to an extent. Personally I find a normal |
With |
Is the status still the same in here? As far as I could see in 4fb42e4 the "breaker" object - and therefore the only way to break the |
Outside devs were never able to access that object, only internal underscore functions.
Yup. |
Ah didn't realize that. However what speaks against to create (as already mentioned above), two sentinel constants like One could then write his
Sure it's more "complicated" compared to the |
I'm opposed to this. Maybe a special sentinel value, but not a common everyday value that lots of iteratees are likely to return by coincidence. Then still, |
Now that
_.each
no longer uses the nativeforEach
it can break whenfalse
is returned.