{"size": 610, "ext": "js", "max_stars_repo_path": "src/ImmutableOptimizations.js", "max_stars_repo_name": "dustingetz/react-cursor", "max_stars_repo_stars_event_min_datetime": "2015-01-02T18:25:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-05T17:50:19.000Z", "max_issues_repo_path": "src/ImmutableOptimizations.js", "max_issues_repo_name": "dustingetz/react-cursor", "max_issues_repo_issues_event_min_datetime": "2015-01-22T00:16:16.000Z", "max_issues_repo_issues_event_max_datetime": "2016-09-21T14:38:19.000Z", "max_forks_repo_path": "src/ImmutableOptimizations.js", "max_forks_repo_name": "dustingetz/react-cursor", "max_forks_repo_forks_event_min_datetime": "2015-01-22T12:42:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-29T17:57:27.000Z"}
{"max_stars_count": 540, "max_issues_count": 66, "max_forks_count": 36, "avg_line_length": 25.4166666667, "max_line_length": 70, "alphanum_fraction": 0.6819672131}
import omit from 'lodash.omit';
import isEqual from 'lodash.isequal';


function ImmutableOptimizations (refFields = [], ignoredFields = []) {
  var noValueCheckFields = refFields.concat(ignoredFields);
  return {
    shouldComponentUpdate: function (nextProps) {

      var valuesChanged = !isEqual(
        omit(nextProps, noValueCheckFields),
        omit(this.props, noValueCheckFields));

      var refsChanged = !refFields.every((field) => {
        return this.props[field] === nextProps[field];
      });

      return valuesChanged || refsChanged;
    }
  };
}

export default ImmutableOptimizations;
