<commit_before>import { Events } from './events';
import { Render } from '../index';
import { Utils } from './utils';
class Component {
  constructor(props) {
    // generate a unique id for this rendering
    this.guid = Utils.guid();
    // setup empty props
    console.log(this, '>>>', props);
    this.props = props;
    // set state
    this.setState = state => {
      this.state = merge(this.state, state);
      Render(this);
    };
  }
}

// utility function to merge
function merge(obj1, obj2) {
  var obj3 = {};
  for (var attrname in obj1) {
    obj3[attrname] = obj1[attrname];
  }
  for (var attrname in obj2) {
    obj3[attrname] = obj2[attrname];
  }
  return obj3;
}

// export component<commit_msg>add callback to Component.setState, use Object.assign instead of for-loop to deep clone/merge state<commit_after>import { Events } from './events';
import { Render } from '../index';
import { Utils } from './utils';
class Component {
  constructor(props) {
    // generate a unique id for this rendering
    this.guid = Utils.guid();
    // setup empty props
    console.log(this, '>>>', props);
    this.props = props;
    // set state
    this.setState = (state, cb) => {
      this.state = merge(this.state, state);
      Render(this);

      if (cb) {
        cb();
      }
    };
  }
}

// utility function to deep clone/merge
function merge(a, b) {
  const c = Object.assign({}, a, b);
  return c;
}

// export component
{'fraction_non_alphanumeric': 0.15038115038115038, 'fraction_numerical': 0.00693000693000693, 'mean_word_length': 2.63727959697733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3464285', 'n_tokens_mistral': 456, 'n_tokens_neox': 459, 'n_words': 137}