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

feat: add option to run parallel in order #371

Closed
wants to merge 3 commits into from

Conversation

Fjandin
Copy link

@Fjandin Fjandin commented Dec 12, 2023

Description

Adds an extra optional option to the parallel method {executeInOrder?: boolean}

  • executeInOrder: true will make the parallel method pick from the array in order

Example

const userIds = [1, 2, 3, 4, 5]
const users = await parallel(3, userIds, async (userId) => {
  return await api.users.find(userId)
}, {executeInOrder: true})

Checklist

  • Changes are covered by tests if behavior has been changed or added
  • Tests have 100% coverage
  • If code changes were made, the version in package.json has been bumped (matching semver)
  • If code changes were made, the yarn build command has been run and to update the cdn directory
  • If code changes were made, the documentation (in the /docs directory) has been updated

Copy link

vercel bot commented Dec 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2023 9:08am

@Fjandin Fjandin marked this pull request as ready for review December 12, 2023 09:07
@sodiray
Copy link
Owner

sodiray commented Feb 21, 2024

@Fjandin thanks for the PR 🙏 It's possible I'm missing something but isn't executing the functions in order make it the opposite of executing them in parallel? Could you just not use the parallel function?

@sodiray
Copy link
Owner

sodiray commented Feb 21, 2024

On second look at the PR I see, they're still parallel but in order... still a bit confused tho. I'm curious, what's your use case?

@Fjandin
Copy link
Author

Fjandin commented Jun 18, 2024

@sodiray Sorry for the late reply. Some time since, so don't remember the details, but had a weird case where i needed the tasks to be picked out in order. However now that I look at it again, I can see i could just as well just reverse the array of tasks :P And yeah, the fact that I guess the order shouldn't really matter in parallel execution.
I'm just gonna close it. I can see this is a unnecessary complexion to add. Have a nice day :)

@Fjandin Fjandin closed this Jun 18, 2024
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.

2 participants