<commit_before>'use strict'

var assign = require('object-assign')
var EventEmitter = require('eventemitter3')
var objEql = require('obj-eql')

function createStore(obj) {
  var store = assign(Object.create(EventEmitter.prototype), {
    state: {},
    setState: function(change) {
      var newState = Object.freeze(assign({}, this.state, change))
      updateState(this, newState)
    },
    replaceState: function(newState) {
      newState = Object.freeze(assign({}, newState))
      updateState(this, newState)
    }
  }, obj)
  Object.freeze(store.state)
  return store
}

function updateState(store, newState) {
  if (!objEql(newState, store.state)) {
    store.state = newState
    store.emit('change')
  }
}

module.exports = createStore<commit_msg>Refactor replaceState to handle all state updates<commit_after>'use strict'

var assign = require('object-assign')
var EventEmitter = require('eventemitter3')
var objEql = require('obj-eql')

function createStore(obj) {
  var store = assign(Object.create(EventEmitter.prototype), {
    state: {},
    setState: function(change) {
      this.replaceState(assign({}, this.state, change))
    },
    replaceState: function(newState) {
      if (!objEql(newState, this.state)) {
        this.state = Object.freeze(newState)
        this.emit('change')
      }
    }
  }, obj)
  Object.freeze(store.state)
  return store
}

module.exports = createStore
{'fraction_non_alphanumeric': 0.13665480427046264, 'fraction_numerical': 0.0014234875444839859, 'mean_word_length': 3.9160839160839163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7107197', 'n_tokens_mistral': 441, 'n_tokens_neox': 442, 'n_words': 89}