{"size": 818, "ext": "js", "max_stars_repo_path": "node_modules/@zippytech/react-toolkit/__src/TreeView/src/utils/changeChildrenProperty.js", "max_stars_repo_name": "lauriefacer/Facer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@zippytech/react-toolkit/__src/TreeView/src/utils/changeChildrenProperty.js", "max_issues_repo_name": "lauriefacer/Facer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/@zippytech/react-toolkit/__src/TreeView/src/utils/changeChildrenProperty.js", "max_forks_repo_name": "lauriefacer/Facer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.0588235294, "max_line_length": 66, "alphanum_fraction": 0.6931540342}
/**
 * Copyright (c) 2015-present, Zippy Technologies
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import assign from '../../../common/assign';

/**
 * Returns a map with all it children
 * checked or uncheded, depending on
 * check value
 * @param {Object} nodeProps - nodeProps
 * @param {Bool} checked
 * @return {Object} checkMap
 */
function changeChildrenProperty(nodeProps, newState) {
  let propertyMap = { [nodeProps.path]: newState };
  if (nodeProps.children) {
    const children = nodeProps.children.map(child =>
      changeChildrenProperty(child.props, newState)
    );

    children.forEach(child => {
      assign(propertyMap, child);
    });
  }

  return propertyMap;
}

export default changeChildrenProperty;
