<commit_before>import StateMachine from 'fsm-as-promised';
import stampit from 'stampit';
import {flatten, startsWith} from 'lodash/fp';
import {assign} from 'lodash';

const startsWithOn = startsWith('on');

const FSM = stampit({
  props: {
    events: []
  },
  static: {
    initial (state) {
      return this.props({initial: state});
    },
    final (...args) {
      args = flatten(args);
      return this.props({final: args});
    },
    events (...args) {
      args = flatten(args);
      return this.props({events: this.fixed.props.events.concat(args)});
    },
    event (obj) {
      return this.props({events: this.fixed.props.events.concat(obj)});
    },
    callback (name, func) {
      if (!startsWithOn(name)) {
        name = `on${name}`;
      }
      name = name.toLowerCase();
      const callbacks = assign({},
        this.fixed.refs.callbacks,
        {[name]: func});
      return this.refs({callbacks});
    },
    callbacks (obj) {
      // TODO validate
      const callbacks = assign({}, this.fixed.refs.callbacks, obj);
      return this.refs({callbacks});
    }
  }
}).compose(StateMachine);

export default FSM;<commit_msg>reformat FSM<commit_after>import StateMachine from 'fsm-as-promised';
import stampit from 'stampit';
import {flatten, startsWith} from 'lodash/fp';
import {assign} from 'lodash';

const startsWithOn = startsWith('on');

const FSM = stampit({
  props: {
    events: []
  },
  static: {
    initial (state) {
      return this.props({initial: state});
    },
    final (...args) {
      args = flatten(args);
      return this.props({final: args});
    },
    events (...args) {
      args = flatten(args);
      return this.props({events: this.fixed.props.events.concat(args)});
    },
    event (obj) {
      return this.props({events: this.fixed.props.events.concat(obj)});
    },
    callback (name, func) {
      if (!startsWithOn(name)) {
        name = `on${name}`;
      }
      name = name.toLowerCase();
      const callbacks = assign({}, this.fixed.refs.callbacks, {[name]: func});
      return this.refs({callbacks});
    },
    callbacks (obj) {
      // TODO validate
      const callbacks = assign({}, this.fixed.refs.callbacks, obj);
      return this.refs({callbacks});
    }
  }
})
  .compose(StateMachine);

export default FSM;
{'fraction_non_alphanumeric': 0.1676802780191138, 'fraction_numerical': 0.0, 'mean_word_length': 2.7447154471544715, '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': '2706421', 'n_tokens_mistral': 751, 'n_tokens_neox': 744, 'n_words': 164}