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

node.find? #94

Closed
jacobp100 opened this issue Jul 20, 2017 · 2 comments · Fixed by #155
Closed

node.find? #94

jacobp100 opened this issue Jul 20, 2017 · 2 comments · Fixed by #155

Comments

@jacobp100
Copy link

It would be useful to have a node#find function.

In addition, in Lodash, returning false in a forEach callback exits early. This would be useful in node#each for performance optimisations for custom iteration functions.

Happy to submit a PR if you want to go in this direction.

@mbostock
Copy link
Member

mbostock commented Nov 1, 2017

I’d support a node.find PR.

I wouldn’t support short-circuiting node.each if the callback returns false, though; that would not be backwards compatible nor consistent with standard array methods. It’d be better to either use node.find for that purpose, or if we like, we could have node.some and node.every methods equivalent to the standard array methods.

@mbostock mbostock changed the title Implement node#find, shortcut return node#each node.find? Oct 22, 2019
@mbostock
Copy link
Member

Added in 5e8701c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants