By default, giving a schema,
If the incoming new data is the same key, append the new data to the values of the schema keys.
delete keys that are not compatible with the schema.
Example
const schema = {
isPro: false,
darkMode: false,
pages: {
home: false,
settings: false,
},
}
const result = defu(schema, { isPro: 'bbb', d: 'c', pages: { home: true } }, {schema: true})
console.log(result) // {isPro: 'bbb', darkMode: false, pages: { home: true, settings: false } }
By default, giving a schema,
If the incoming new data is the same key, append the new data to the values of the schema keys.
delete keys that are not compatible with the schema.
Example