-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
node -v
v22.11.0
Reproduction
See Describe the bug
Describe the bug
import { defuFn } from 'defu'
const filterDist = (val: string[]) => val.filter(i => i !== 'dist')
const addTwenty = (val: number) => val + 20
const addTen = (val: number) => val + 10
const res = defuFn(
{
count: addTwenty,
num: addTen,
items: filterDist,
},
{
count: 10,
num: 5,
items: ['node_modules', 'test'],
},
{
count: 5,
num: 3,
items: ['temp', 'dist'],
},
)
console.dir({ res }, { depth: 5 })
// expected:
/*
{
res: {
count: 30,
num: 15,
items: [ "node_modules", "test", "temp"]
}
}
*/
// received:
/*
{
res: {
count: 30,
num: 15,
items: [ "node_modules", "test", "temp", "dist" ]
}
}
*/Additional context
When entering the second loop, the function has already been replaced with a value
Line 53 in 70cffe5
| arguments_.reduce((p, c) => _defu(p, c, "", merger), {} as any); |
Logs
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working