UNPKG

594 BJavaScriptView Raw
1import mergeWith from 'lodash/mergeWith';
2import isEqual from 'lodash/isEqual';
3import { logger } from '@storybook/client-logger';
4export default ((a, b) => mergeWith({}, a, b, (objValue, srcValue) => {
5 if (Array.isArray(srcValue) && Array.isArray(objValue)) {
6 srcValue.forEach(s => {
7 const existing = objValue.find(o => o === s || isEqual(o, s));
8
9 if (!existing) {
10 objValue.push(s);
11 }
12 });
13 return objValue;
14 }
15
16 if (Array.isArray(objValue)) {
17 logger.log(['the types mismatch, picking', objValue]);
18 return objValue;
19 }
20
21 return undefined;
22}));
\No newline at end of file