-
Notifications
You must be signed in to change notification settings - Fork 22
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: merge objects with Module
type
#121
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #121 +/- ##
==========================================
+ Coverage 44.74% 45.73% +0.99%
==========================================
Files 4 4
Lines 219 223 +4
Branches 33 35 +2
==========================================
+ Hits 98 102 +4
Misses 119 119
Partials 2 2 β View full report in Codecov by Sentry. |
src/defu.ts
Outdated
@@ -57,8 +56,7 @@ function _isPlainObject(value: unknown): boolean { | |||
(prototype === null || | |||
prototype === Object.prototype || | |||
Object.getPrototypeOf(prototype) === null) && | |||
!(Symbol.toStringTag in value) && | |||
!(Symbol.iterator in value) | |||
(!(Symbol.toStringTag in value) || !(Symbol.iterator in value)) |
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'm wondering if it is purely for Date merging fix, using instance of Date
would be faster
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.
it isn't. See the linked issue. It also applies to Module
(import via *)
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.
Oh, I see! With this PR want to merge Module instances!
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.
Checking, this logic currently basically bypasses entire L59 as iterator
symbol does not exist in any of tested values (removing the line also all the tests pass). Wondering how we can cover it
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.
Oh, I see! With this PR want to merge Module instances!
yes indeed ππ»
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.
Checking, this logic currently basically bypasses entire L59 as iterator symbol does not exist in any of tested values (removing the line also all the tests pass). Wondering how we can cover it
Oh, I see π€ That's a bit tricky. I also wonder how to cover it then...
But - do we need to? Dates are correctly replaced (not merged) like that too
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 have ported test suite of is-plain-object (see commits to main) and also merged in with this PR. Intrestingly we will be breaking two more tests at least (Math
and native arguments
will be wrongly detected as pure object)
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.
Updated with a logic that precisely works for Module
to reduce (more!) regression chances
π Linked issue
Resolves #119
β Type of change
π Description
π Checklist