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

fix(flattenObject): flatten for nested objects #817

Merged
merged 3 commits into from
Dec 1, 2024
Merged

Conversation

nnnnoel
Copy link
Contributor

@nnnnoel nnnnoel commented Nov 13, 2024

Fixed #816

Copy link

vercel bot commented Nov 13, 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 1, 2024 7:32am

@@ -46,7 +46,12 @@ function flattenObjectImpl(object: object, prefix = ''): Record<string, any> {

if (Array.isArray(value)) {
for (let index = 0; index < value.length; index++) {
result[`${prefixedKey}.${index}`] = value[index];
const valueKey = `${prefixedKey}.${index}`;
if (typeof value[index] === 'object' && value[index] !== null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think non-object filter needed on top of flattenObjectImpl function, but not sure to code convention of es-toolkit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I think we have a simpler logic here; I made a little modification.

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.96%. Comparing base (a46d8c4) to head (f52d1e2).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #817   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files         306      306           
  Lines        2743     2747    +4     
  Branches      818      820    +2     
=======================================
+ Hits         2742     2746    +4     
  Misses          1        1           
---- 🚨 Try these New Features:

Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

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

Thanks for helping us fix the problem!

@raon0211 raon0211 merged commit 7d9b11d into toss:main Dec 1, 2024
5 of 8 checks passed
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.

flattenObject doesn't handle array of objects
3 participants