Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: ensure merger function works correctly with multiple defaults #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/defu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ function _defu<T>(
// Create defu wrapper with optional merger and multi arg support
export function createDefu(merger?: Merger): DefuFunction {
return (...arguments_) =>
// eslint-disable-next-line unicorn/no-array-reduce
arguments_.reduce((p, c) => _defu(p, c, "", merger), {} as any);
_defu(
arguments_[0],
// eslint-disable-next-line unicorn/no-array-reduce
arguments_.slice(1).reduce((p, c) => _defu(p, c, "", merger), {} as any),
"",
merger,
) as any;
}

// Standard version
Expand Down