From aa1f0a8432a7a918c36486e8b2334ef12ff4f46b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 22 Aug 2024 10:47:46 -0700 Subject: [PATCH] [Fix] `utils.merge`: functions should not be stringified into keys --- lib/utils.js | 2 +- test/utils.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index d4e19566..d325ffdb 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -50,7 +50,7 @@ var merge = function merge(target, source, options) { return target; } - if (typeof source !== 'object') { + if (typeof source !== 'object' && typeof source !== 'function') { if (isArray(target)) { target.push(source); } else if (target && typeof target === 'object') { diff --git a/test/utils.js b/test/utils.js index 21429937..7a4ff1b2 100644 --- a/test/utils.js +++ b/test/utils.js @@ -38,8 +38,8 @@ test('merge()', function (t) { func.bar = 'baz'; t.deepEqual( utils.merge({ foo: 'bar' }, func), - { foo: 'bar', 'function f() {}': true }, - 'functions can not be merge sources' + { foo: 'bar', bar: 'baz' }, + 'functions can be merge sources' ); t.test(