radashi-org / radashi

The modern, community-first TypeScript toolkit with all of the fast, readable, and minimal utility functions you need. Type-safe, dependency-free, tree-shakeable, fully tested.
https://radashi.js.org
MIT License
314 stars 25 forks source link

feat(parallel): clamp the limit between 1 and array length #238

Closed MarlonPassos-git closed 1 day ago

MarlonPassos-git commented 2 months ago

[!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 https://github.com/sodiray/radash/issues/426

For any code change,

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size [^1337] Difference
M src/async/parallel.ts 1698 +135 (+9%)

[^1337]: Function size includes the import dependencies of the function.

aleclarson commented 3 weeks ago

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 commented 1 week ago

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 commented 1 week ago

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 🫡

radashi-bot commented 1 day ago

A stable release 12.3.0 has been published to NPM. :rocket:

To install:

pnpm add radashi@12.3.0

See the changes