From d646f7463cd5f027709116928432edb88b266fa6 Mon Sep 17 00:00:00 2001
From: byronogis <byronogis@outlook.com>
Date: Fri, 13 Dec 2024 22:03:47 +0800
Subject: [PATCH] fix: ensure merger function works correctly with multiple
 defaults

---
 src/defu.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/defu.ts b/src/defu.ts
index 271c023..854d204 100644
--- a/src/defu.ts
+++ b/src/defu.ts
@@ -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