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
{{ message }}
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since we will be using this function a lot more, this change would make it really useful to do a search inside an object and stop when finding the result by making the callback return a value that will be false once the search is done. This is the same way that jQuery uses to break the .each loops.
I've been using Array.some a lot more lately and it seems useful to have a return value, so I removed the break in forEach and added a new some function, which also makes it more consistence with the Array functions.
@TomMalbran done reviewing. Two comment nits plus this bigger question about whether we want to rename the API. We should probably wait a day or so to see if others chime in on that.
It seems like I missed several cases when switching $.each with forEach where the loop broke. This fixes one of those cases, since it needs CollectionUtils.some to work.
@peterflynn It's been a few days, and nothing happened, should we just leave like it is. The names make sense since the functions work for any collection, and JavaScript already implements different APIs with the same names.
@peterflynn Great, I am glad that this is finally merged :) I know it shouldn't be used for arrays, but it is possible. It would work great when the object could be either an array or an object. Thanks for changing the name, this pull went from breaking the loop to creating a new method.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since we will be using this function a lot more, this change would make it really useful to do a search inside an object and stop when finding the result by making the callback return a value that will be false once the search is done. This is the same way that jQuery uses to break the .each loops.