<commit_before>var assign = require("react/lib/Object.assign");

var _listeners = [];
var _state = {};

var EditorStore = {
  set(state, notify) {
    notify = notify !== false;
    _state = assign(_state, state);
    if (notify) { this.notify(); }
  },

  get() {
    return _state;
  },

  addChangeListener(onChange) {
    _listeners.push(onChange);
  },

  removeChangeListener(onChange) {
    var index = _listeners.indexOf(onChange);

    if (index > -1) {
      _listeners.splice(index, 1);
    }
  },

  notify() {
    _listeners.forEach((onChange) => onChange(this));
  }
};

module.exports = EditorStore;
<commit_msg>add method to only get changes from last store change<commit_after>var assign = require("react/lib/Object.assign");
var pick   = require("lodash.pick");

var _listeners = [];
var _state = {};
var _changed = [];

var EditorStore = {
  set(state, emit) {
    emit = emit !== false;
    _state = assign(_state, state);
    _changed = Object.keys(state);
    if (emit) { this.emit(); }
  },

  get() {
    return _state;
  },

  getChanged() {
    return pick(_state, _changed);
  },

  addChangeListener(onChange) {
    _listeners.push(onChange);
  },

  removeChangeListener(onChange) {
    var index = _listeners.indexOf(onChange);

    if (index > -1) {
      _listeners.splice(index, 1);
    }
  },

  emit() {
    _listeners.forEach((onChange) => onChange(this));
  }
};

module.exports = EditorStore;

{'fraction_non_alphanumeric': 0.1586303284416492, 'fraction_numerical': 0.002795248078266946, 'mean_word_length': 3.211764705882353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5906199', 'n_tokens_mistral': 496, 'n_tokens_neox': 483, 'n_words': 98}