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

eachFind: first draft #9

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

eachFind: first draft #9

wants to merge 1 commit into from

Conversation

HGZdev
Copy link

@HGZdev HGZdev commented Oct 14, 2020

I would like to shyly propose a new db search function .eachFind. It will works as .each until callback function fn returns the first positive result. Precisely, all fn's grouped in particular settleAll will be executed, but it is still a progress in compare to .each's full execution.

@wmertens
Copy link
Collaborator

wmertens commented Oct 14, 2020

I think this should return the found result, no?

As for the naming, I'm 90% ok with it, but I wonder if something like eachUntil might be better?

2 more considerations:

  • each could also do this, by passing a stop token; if you return it, processing stops: .each( (item, STOP) => item.bar && STOP). Then we wouldn't need an extra method.
  • I want to change the current meaning of limit, it is currently used to choose the number of items per run, I think it should mean the number of items total. Instead there should be something like pageSize = 50 and workers = 5 to load results per 50 and run 5 fns in parallel

@Dzieni
Copy link
Contributor

Dzieni commented Oct 15, 2020

Personally I'm more into doing this inside each, one function less to remember

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.

3 participants