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 partition static function #526

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

b-michalkiewicz
Copy link

Hi,

added partition function to handle scenarios when you need to get a tuple of all results and errors. Inspired by lodash partition

@b-michalkiewicz
Copy link
Author

Hi @supermacro,

Any thoughts about this one? Thanks!

Comment on lines +72 to +78
static partition<
T extends readonly [ResultAsync<unknown, unknown>, ...ResultAsync<unknown, unknown>[]]
>(asyncResultList: T): PartitionResultAsync<T>
static partition<T extends readonly ResultAsync<unknown, unknown>[]>(
asyncResultList: T,
): PartitionResultAsync<T>
static partition<T extends readonly ResultAsync<unknown, unknown>[]>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following why we need to overload this fn. Please explain.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these overloads have no meaning.

partition will flatten tuple type to array of union by its nature.

Type checking of this test passes even if you remove overloads
https://github.com/supermacro/neverthrow/pull/526/files?w=1#diff-cece62ae24396a5d51e8f2a2cb3abba900652084488023f4de9669eaaf6f81e8R572-R579

@supermacro supermacro added the help wanted Extra attention is needed label Sep 11, 2024
@supermacro
Copy link
Owner

Added help wanted as there are conflicts and unanswered comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants