@outputai/core 0.10.1-dev.b7b2fbe.0 → 0.10.1-next.64a9df7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/helpers/object.js
CHANGED
|
@@ -44,7 +44,11 @@ export const deepMergeWithResolver = ( base, ...args ) => {
|
|
|
44
44
|
const resolver = args.at( -1 );
|
|
45
45
|
|
|
46
46
|
if ( !isPlainObject( base ) ) {
|
|
47
|
-
throw new Error( 'First argument is not an object.' );
|
|
47
|
+
throw new Error( 'First argument (base object) is not an object.' );
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if ( typeof resolver !== 'function' ) {
|
|
51
|
+
throw new Error( 'Last argument (resolver) is not a function.' );
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
return objects.reduce( ( merged, object ) => {
|
|
@@ -224,6 +224,11 @@ describe( 'deepMergeWithResolver', () => {
|
|
|
224
224
|
expect( () => deepMergeWithResolver( 'a', {}, ( x, y ) => x + y ) ).toThrow( Error );
|
|
225
225
|
} );
|
|
226
226
|
|
|
227
|
+
it( 'throws when last argument is not a resolver function', () => {
|
|
228
|
+
expect( () => deepMergeWithResolver( { a: 1 }, { a: 2 } ) )
|
|
229
|
+
.toThrow( 'Last argument (resolver) is not a function.' );
|
|
230
|
+
} );
|
|
231
|
+
|
|
227
232
|
it( 'merges multiple objects using the resolver from left to right', () => {
|
|
228
233
|
const resolver = vi.fn( ( x, y ) => `${ x }:${ y }` );
|
|
229
234
|
|