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(groupBy): Updated groupBy to accept string as a second argument #917

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

weijunyu
Copy link

@weijunyu weijunyu commented Dec 31, 2024

Change

Instead of a key-generating function, callers can now pass a string as the key that they wish to group items by.

Rationale

In lodash, groupBy also accepts strings as its second argument as a shorthand for getting the key to group items on.

This will allow users to do a 1 for 1 replacement with lodash.groupBy.

Instead of a key-generating function, callers can now pass a string as
the key that they wish to group items by.
Copy link

vercel bot commented Dec 31, 2024

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

Name Status Preview Comments Updated (UTC)
es-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 8:09am

@weijunyu weijunyu changed the title Updated groupBy to accept string as a second argument. Feat(groupBy): Updated groupBy to accept string as a second argument Dec 31, 2024
@@ -45,3 +45,21 @@ describe('groupBy/largeArray', () => {
groupByLodash(largeArray, item => item.category);
});
});

describe('groupBy/stringKey', () => {
Copy link
Author

@weijunyu weijunyu Dec 31, 2024

Choose a reason for hiding this comment

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

CleanShot 2024-12-31 at 15 03 21

@weijunyu weijunyu marked this pull request as ready for review December 31, 2024 07:06
@weijunyu weijunyu requested a review from raon0211 as a code owner December 31, 2024 07:06
@raon0211
Copy link
Collaborator

raon0211 commented Jan 2, 2025

Hello, this is actually what we will support in our compatibility library. Would you add this similar to this pull request?

#860

If not, we might work on this soon.

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