<commit_before>module.exports = (function() {

  var findState = function(curr, events) {
    for(var i = 0; i < events.length; i++) {
      if(events[i].from === curr) return events[i]
    }
  }

  var findNext = function(curr, events) {
    return findState(curr, events).to
  }

  var findEvent = function(event, events) {
    for(var i = 0; i < events.length; i++) {
      if(events[i].name === event) return events[i]
    }
  }

  function ViewStateMachine(options) {
    this.current = options.initial
    this.events = options.events

    this._listeners = {
      transition: []
    }

    // create dynamic event methods
    this.events.forEach(function(event) {
      var action = event.name

      ViewStateMachine.prototype[action] = function() {
        var movingTo = findEvent(action, this.events).to

        if(this.next() === movingTo) {
          this.advance()
        }

        return this
      }

    }.bind(this))
  }

  ViewStateMachine.prototype.advance = function() {<commit_msg>Minor<commit_after>module.exports = (function() {

  var findState = function(curr, events) {
    for(var i = 0; i < events.length; i++) {
      if(events[i].from === curr) return events[i]
    }
  }

  var findNext = function(curr, events) {
    return findState(curr, events).to
  }

  var findEvent = function(event, events) {
    for(var i = 0; i < events.length; i++) {
      if(events[i].name === event) return events[i]
    }
  }

  var createMethod = function(event) {
    var action = event.name

    ViewStateMachine.prototype[action] = function() {
      var movingTo = findEvent(action, this.events).to

      if(this.next() === movingTo) {
        this.advance()
      }

      return this
    }
  }

  function ViewStateMachine(options) {
    this.current = options.initial
    this.events = options.events

    this._listeners = {
      transition: []
    }

    // create dynamic event methods
    this.events.forEach(createMethod.bind(this))
  }

  ViewStateMachine.prototype.advance = function() {
{'fraction_non_alphanumeric': 0.13699307616221562, 'fraction_numerical': 0.0019782393669634025, 'mean_word_length': 2.606060606060606, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6503709', 'n_tokens_mistral': 652, 'n_tokens_neox': 626, 'n_words': 136}