Skip to content
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

Return false when loop break in each #13

Open
redgeoff opened this issue Nov 17, 2017 · 0 comments
Open

Return false when loop break in each #13

redgeoff opened this issue Nov 17, 2017 · 0 comments

Comments

@redgeoff
Copy link
Owner

redgeoff commented Nov 17, 2017

In https://github.com/redgeoff/sporks/blob/master/scripts/collection.js#L11 return false as this way the outer each() can exit when the nested each exits, e.g.

var items = {
  a: { a1: 1, a2: 2 },
  b: { b1: 1, b2: 2}
};
sporks.each(items, function (i, nestedItems) {
  var inner = sporks.each(nestedItems, function (j) {
    if (j === 'a2') {
      return false;
    }
  });
  if (!inner) {
    return false
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant