<commit_before>import dispatcher from '../core/Dispatcher';
import events, {EventEmitter} from 'events';
import _ from 'lodash';

import ActionTypes from '../constants/ActionTypes';
var CHANGE_EVENT = 'change';

var _currentWords = null;

var GameStore = _.assign({}, EventEmitter.prototype, {

  init: function (strofe) {
    if(strofe){
      _currentWords = strofe.split(' ');
    }
  },

  getWords: function(){
    return _currentWords;
  },

  emitChange: function () {
    this.emit(CHANGE_EVENT);
  },

  /**
   * @param {function} callback
   */
  addChangeListener: function (callback) {
    this.on(CHANGE_EVENT, callback);
  },

  /**
   * @param {function} callback
   */
  removeChangeListener: function (callback) {
    this.removeListener(CHANGE_EVENT, callback);
  }

});


GameStore.dispatchToken = dispatcher.register(function (action) {
  switch (action.type) {
    case ActionTypes.STROFE_CHANGED:
      GameStore.init(action.strofe);
      GameStore.emitChange();
      break;
    default:
    //do nothing
  }
});

export default GameStore;<commit_msg>Made store into ES6 class<commit_after>import dispatcher from '../core/Dispatcher';
import EventEmitter from 'events';
import _ from 'lodash';

import ActionTypes from '../constants/ActionTypes';

const CHANGE_EVENT = 'change';
let _currentWords = [];
let _displayedScreens = {};

class GameStore extends EventEmitter {
  
  init(strofe) {
    if (strofe) {
      _currentWords = strofe.split(' ');
      _displayedScreens = {};
      _.forEach(_currentWords, (word, index) => {
        _displayedScreens[index] = false;
      });
    }
  }

  getWords(){
    return _currentWords;
  }

  emitChange () {
    this.emit(CHANGE_EVENT);
  }

  /**
   * @param {function} callback
   */
  addChangeListener (callback) {
    this.on(CHANGE_EVENT, callback);
  }

  /**
   * @param {function} callback
   */
  removeChangeListener (callback) {
    this.removeListener(CHANGE_EVENT, callback);
  }
}

const store = new GameStore();

store.dispatchToken = dispatcher.register(function (action) {
  switch (action.type) {
    case ActionTypes.STROFE_CHANGED:
      store.init(action.strofe);
      store.emitChange();
      break;
    case ActionTypes.SHOW_SCREEN:
      _displayedScreens[action.screen] = true;
      store.emitChange();    
    default:
    //do nothing
  }
});

export default store;
{'fraction_non_alphanumeric': 0.13302364864864866, 'fraction_numerical': 0.0004222972972972973, 'mean_word_length': 3.2839059674502713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6924799', 'n_tokens_mistral': 771, 'n_tokens_neox': 746, 'n_words': 155}