-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/object/flattenObject.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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
|
There was a problem hiding this 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!
Fixed #816