/* eslint-disable no-use-before-define */
const cloneArray = array => array.map(item => cloneDeep(item));

const cloneObject = object => {
  const clone = {};
  Object.keys(object).forEach(key => {
    clone[key] = cloneDeep(object[key]);
  });
  return clone;
};

/* eslint-enable no-use-before-define */

const cloneDeep = object => {
  if (Array.isArray(object)) {
    // is an array
    return cloneArray(object);
  } else if (object && typeof object === 'object' && Object.keys(object).length) {
    // is an object
    return cloneObject(object);
  }
  // Do not bother converting other values.
  return object;
};

export { cloneDeep as default };

@@ -1,16 +1,67 @@
+import isPlainObject from 'lodash/isPlainObject';%0A%0A
 /* eslint-disabl
@@ -489,57 +489,29 @@
  && 
-typeof object === 'object' && 
+isPlain
 Object
-.keys
 (object)
 .len
@@ -510,15 +510,8 @@
 ect)
-.length
 ) %7B%0A

Update cloneDeep to properly check for plain objects. Fixes issue where intially empty objects would not be cloned.