unjs / defu

🌊 Assign default properties recursively
MIT License
1.06k stars 22 forks source link

fix: only merge plain objects #111

Closed pi0 closed 1 year ago

pi0 commented 1 year ago

πŸ”— Linked issue

resolves #100

❓ Type of change

πŸ“š Description

When merging two objects, we were not checking if two objects are not pure object and also using Object.assign to merge even classes, which can lead to unwanted behavior such as merging two Date values.

This PR fixes this issue by adding little bit of overhead to the checks using a fork of is-plain-obj

πŸ“ Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #111 (06ba4d8) into main (59d0f6a) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #111   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           79        92   +13     
  Branches        24        28    +4     
=========================================
+ Hits            79        92   +13     
Files Coverage Ξ”
src/defu.ts 100.00% <100.00%> (ΓΈ)