Make _.each break when false is returned#1545
Make _.each break when false is returned#1545melnikov-s wants to merge 1 commit intojashkenas:masterfrom
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
_.eachno longer uses the nativeforEachit can break whenfalseis returned.