unjs / defu

🌊 Assign default properties recursively
MIT License
1.02k stars 21 forks source link

Warn if property with the same value is overridden #128

Open enkot opened 5 months ago

enkot commented 5 months ago

Describe the feature

In a large project, it is difficult to track/manage when developers specify properties with a value that already exists in the default object. It would be nice to add a warning option if redundant duplication occurs:

const defuFn = createDefu({ 
  warnDuplicates: true
})

On the other hand, I guess it's better not to cause side effects, maybe a callback?

const defuFn = createDefu({ 
  onDuplicate: (object, key, value) => {}
})

Additional information