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

Add find and findIndex methods #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nlwillia
Copy link

This adds a couple of methods that are useful for locating specific elements as part of a lazy, array-like traversal. Without them you would have to use some or reduce or toArray which are inefficient if you just want to locate an element and quit. This could be generalized with a (hypothetical) reduceUntil method, but I think the find cases are conventional enough to be expected and be worth supporting directly as is already done with some.

See:
find (MDN)
findIndex (MDN)

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

Successfully merging this pull request may close these issues.

1 participant