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(parallel): clamp the limit between 1 and array length #238

Conversation

MarlonPassos-git
Copy link
Contributor

@MarlonPassos-git MarlonPassos-git commented Sep 8, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

now:

const array = [1, 2, 3]
const doSomething = async (n: number) => { ...}
_.parallel(-1, array, doSomething) // run 1 function in paraller (in the current implementation no function is executed)
_.parallel(0, array, doSomething) // run 1 function in paraller (in the current implementation no function is executed)
_.parallel(100, array, doSomething) // run 3 function in paraller 
_.parallel(Infinity, array, doSomething) // run 3 function in paraller (in the current implementation this throws an error)

Related issue, if any:

https://github.com/orgs/radashi-org/discussions/235
sodiray/radash#426

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1 Difference
M src/async/parallel.ts 1698 +135 (+9%)

Footnotes

  1. Function size includes the import dependencies of the function.

@MarlonPassos-git MarlonPassos-git changed the title feat(parallel): limit handle with infinity and negative numbers feat(parallel): limit handle with infinity, zero and negative numbers Sep 8, 2024
@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Sep 21, 2024
@aleclarson aleclarson added this to the v12.3.0 milestone Sep 21, 2024
@aleclarson
Copy link
Member

Hey! There's a new requirement for PRs that introduce new features. Without this requirement met, we won't be able to merge this. Note that this PR can still be included in a beta prerelease before this requirement is fulfilled.

⚠️ Note: You need to run git rebase main before this file will appear locally.

@aleclarson aleclarson added prerelease Publish to NPM under the "beta" or "next" tag and removed prerelease Publish to NPM under the "beta" or "next" tag labels Nov 11, 2024
aleclarson
aleclarson previously approved these changes Nov 11, 2024
@aleclarson aleclarson added prerelease Publish to NPM under the "beta" or "next" tag and removed prerelease Publish to NPM under the "beta" or "next" tag labels Nov 11, 2024
@aleclarson aleclarson added prerelease Publish to NPM under the "beta" or "next" tag and removed prerelease Publish to NPM under the "beta" or "next" tag labels Nov 21, 2024
@aleclarson aleclarson force-pushed the feature/parallel-handle-with-infinity-and-negative-numbers branch from b697e83 to f49c9d4 Compare November 21, 2024 13:22
aleclarson
aleclarson previously approved these changes Nov 21, 2024
@aleclarson aleclarson force-pushed the feature/parallel-handle-with-infinity-and-negative-numbers branch from f49c9d4 to ea7ca47 Compare November 21, 2024 13:26
@aleclarson aleclarson added prerelease Publish to NPM under the "beta" or "next" tag and removed prerelease Publish to NPM under the "beta" or "next" tag labels Nov 21, 2024
@aleclarson aleclarson modified the milestones: v12.3.0, v12.4.0 Nov 21, 2024
@aleclarson
Copy link
Member

aleclarson commented Nov 21, 2024

Postponing this until v12.4.0, since it conflicts with PR #262 and we don't have an easy way to solve that currently.

Basically, the prerelease tag triggers a GitHub CI workflow that attempts to cherry-pick the PR into the beta branch. If that fails, there's no way to manually fix the merge conflict. In the future, I could add a fail-safe to the CI workflow that would open a “clone” PR targeting the beta branch specifically. Then I could checkout that PR, manually fix the conflict, push the fix, and merge that PR into the beta branch, triggering a prerelease.

@MarlonPassos-git
Copy link
Contributor Author

Postponing this until v12.4.0, since it conflicts with PR #262 and we don't have an easy way to solve that currently.

Basically, the prerelease tag triggers a GitHub CI workflow that attempts to cherry-pick the PR into the beta branch. If that fails, there's no way to manually fix the merge conflict. In the future, I could add a fail-safe to the CI workflow that would open a “clone” PR targeting the beta branch specifically. Then I could checkout that PR, manually fix the conflict, push the fix, and merge that PR into the beta branch, triggering a prerelease.

fixed 🫡

@aleclarson aleclarson force-pushed the feature/parallel-handle-with-infinity-and-negative-numbers branch from 4f5a4bd to 343cfc4 Compare December 1, 2024 16:54
@aleclarson aleclarson modified the milestones: v12.4.0, v12.3.0 Dec 1, 2024
@aleclarson aleclarson changed the title feat(parallel): limit handle with infinity, zero and negative numbers feat(parallel): clamp the limit between 1 and array length Dec 1, 2024
@aleclarson aleclarson merged commit b4854f6 into radashi-org:main Dec 1, 2024
10 checks passed
@radashi-bot
Copy link

A stable release 12.3.0 has been published to NPM. 🚀

To install:

See the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This PR adds a new function or extends an existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants