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(select): let condition be undefined #9

Merged
merged 2 commits into from
Jun 25, 2024
Merged

Conversation

aleclarson
Copy link
Member

Description

If the condition parameter is undefined, the mapper result is checked with != null instead, so null and undefined results are omitted from the new array.

const result = select(
  [{ a: 1 }, { a: 2 }, { b: 1 }],
  (obj) => obj.a,
)

expect(result).toEqual([1, 2])

Checklist

  • Changes are covered by tests if behavior has been changed or added
  • Tests have 100% coverage
  • If code changes were made, the documentation (in the /docs directory) has been updated

Resolves

Resolves sodiray/radash#269

@aleclarson
Copy link
Member Author

Hello @adamhamlin, let me know if this solution makes sense to you. It's based on your feedback in sodiray/radash#269.

I'm open to a selectFirst contribution, too!

Copy link
Contributor

@adamhamlin adamhamlin left a comment

Choose a reason for hiding this comment

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

Hello @adamhamlin, let me know if this solution makes sense to you. It's based on your feedback in sodiray/radash#269.

I'm open to a selectFirst contribution, too!

Yep, looks good! And sure, I can open a PR for selectFirst

@aleclarson
Copy link
Member Author

@adamhamlin I hope you didn't start on that yet. I just reorganized the repository to have one module per function, so rebasing onto main could be annoying. 😅

@aleclarson aleclarson merged commit dc74ace into main Jun 25, 2024
4 checks passed
Copy link

github-actions bot commented Jun 25, 2024

A new beta version 12.2.0-beta.2c63f67 has been published to NPM.

To install:

See the changes

@adamhamlin
Copy link
Contributor

@aleclarson nope, hadn't started yet, no worries!

@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Jun 28, 2024
@adamhamlin adamhamlin mentioned this pull request Jun 29, 2024
2 tasks
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.

Any interest in collect/collectFirst?
2 participants