{"size": 655, "ext": "js", "max_stars_repo_path": "kolibri/core/assets/src/cloneDeep.js", "max_stars_repo_name": "jonboiser/kolibri", "max_stars_repo_stars_event_min_datetime": "2021-03-26T03:44:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-26T03:44:24.000Z", "max_issues_repo_path": "kolibri/core/assets/src/cloneDeep.js", "max_issues_repo_name": "jonboiser/kolibri", "max_issues_repo_issues_event_min_datetime": "2016-06-23T16:01:02.000Z", "max_issues_repo_issues_event_max_datetime": "2018-12-01T22:15:13.000Z", "max_forks_repo_path": "kolibri/core/assets/src/cloneDeep.js", "max_forks_repo_name": "MingDai/kolibri", "max_forks_repo_forks_event_min_datetime": "2021-06-01T23:15:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-01T23:15:26.000Z"}
{"max_stars_count": 1, "max_issues_count": 7, "max_forks_count": 1, "avg_line_length": 24.2592592593, "max_line_length": 82, "alphanum_fraction": 0.6458015267}
/* 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 };
