Skip to content

fix[groupBy, keyBy, countBy]: keep __proto__ as an own property - #2157

Open
frogscooper wants to merge 3 commits into
toss:mainfrom
frogscooper:fix/groupby-keyby-countby-proto
Open

frogscooper wants to merge 3 commits into
toss:mainfrom
frogscooper:fix/groupby-keyby-countby-proto

Conversation

@frogscooper

Copy link
Copy Markdown
Contributor

Summary

If the key function returns "proto", these helpers assign into a plain object the normal way and hit the prototype setter instead of making an own property. The group/key/count gets lost or wrong, and the result's prototype changes. Same bug family as #2117. #2128 already fixed clone/assign/omit/pick but not these.

Changes

Define "proto" with Object.defineProperty in groupBy, keyBy, and countBy. Same in compat groupBy and keyBy. Compat countBy was already fine. Added regression tests.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
es-toolkit Ready Ready Preview Oct 23, 2026 8:19pm UTC

Request Review

@frogscooper frogscooper changed the title fix(groupBy, keyBy, countB): keep __proto__ as an own property fix[groupBy, keyBy, countBy]: keep __proto__ as an own property Oct 23, 2026

This branch was successfully deployed

1 active deployment
Preview — f803f9e0 Deployed Oct 23, 2026 by vercel[bot]
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.

1 participant