<commit_before>import assign from 'lodash.assign'
import diff from 'immutablediff'
import forEach from 'lodash.foreach'
import isArray from 'lodash.isarray'
import keys from 'lodash.keys'
import wrap from 'lodash.wrap'
import defer from 'lodash.defer'

import Utils from './utils'

/* eslint-disable no-console */
class Base {
  constructor() {
    this.state = null
    this.actions = {}
    this.logging = {}
    this.changeHandlers = []
    if (this.initialize) this.initialize()
  }

  getState() {
    return this.state
  }

  setState(state) {
    this.logStateUpdate(this.state, state)
    this.state = state
    this.emitChange()
  }

  updateState(updater) {
    this.setState(updater(this.state))
  }

  mutate(keyPath, value) {
    const kp = isArray(keyPath) ? keyPath : keyPath.split('.')
    const val = typeof value === 'function' ? value(this.getState().getIn(keyPath)) : value
    this.setState(this.getState().setIn(kp, val))<commit_msg>Reference kp instead of keyPath<commit_after>import assign from 'lodash.assign'
import diff from 'immutablediff'
import forEach from 'lodash.foreach'
import isArray from 'lodash.isarray'
import keys from 'lodash.keys'
import wrap from 'lodash.wrap'
import defer from 'lodash.defer'

import Utils from './utils'

/* eslint-disable no-console */
class Base {
  constructor() {
    this.state = null
    this.actions = {}
    this.logging = {}
    this.changeHandlers = []
    if (this.initialize) this.initialize()
  }

  getState() {
    return this.state
  }

  setState(state) {
    this.logStateUpdate(this.state, state)
    this.state = state
    this.emitChange()
  }

  updateState(updater) {
    this.setState(updater(this.state))
  }

  mutate(keyPath, value) {
    const kp = isArray(keyPath) ? keyPath : keyPath.split('.')
    const val = typeof value === 'function' ? value(this.getState().getIn(kp)) : value
    this.setState(this.getState().setIn(kp, val))
{'fraction_non_alphanumeric': 0.13312532501300053, 'fraction_numerical': 0.0, 'mean_word_length': 3.613908872901679, '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': '7165677', 'n_tokens_mistral': 653, 'n_tokens_neox': 637, 'n_words': 147}