<commit_before>import Ember from 'ember';

export default Ember.Helper.extend({
  compute([value = this.default], options) {
    this.options = options;
    if (!this.value || !this._update) {
      this.value = value;
    }
    let current = this.value;
    let actions = Object.keys(this.actions).reduce((actions, key)=> {
      actions[key] = {
        value: (...args)=> {
          let action = this.actions[key];
          var nextState = this.setState((curr) => action.call(null, curr, ...args));
          sendActionNotification(this, key, nextState);
          return nextState;
        }
      };
      return actions;
    }, {});

    return Object.create(this.wrap(current), actions);
  },

  wrap(value) {
    return value;
  },

  setState(updateFn = (current)=> current) {
    this._update = true;
    var nextState = updateFn.call(this, this.value);
    if (nextState !== this.value) {
      this.value = nextState;
      this.recompute();
      sendActionNotification(this, 'state', nextState);
    }
    return this.value;
  }
});

function sendActionNotification(helper, actionName, state) {
  var actionCallback = helper.options[Ember.String.dasherize(`on-${actionName}`)];
  Ember.sendEvent(helper, actionName, state);
  if (actionCallback && actionCallback.call) {
    actionCallback.call(null, state);
  }
}
<commit_msg>make sure to pass state as event arguments<commit_after>import Ember from 'ember';

export default Ember.Helper.extend({
  compute([value = this.default], options) {
    this.options = options;
    if (!this.value || !this._update) {
      this.value = value;
    }
    let current = this.value;
    let actions = Object.keys(this.actions).reduce((actions, key)=> {
      actions[key] = {
        value: (...args)=> {
          let action = this.actions[key];
          var nextState = this.setState((curr) => action.call(null, curr, ...args));
          sendActionNotification(this, key, nextState);
          return nextState;
        }
      };
      return actions;
    }, {});

    return Object.create(this.wrap(current), actions);
  },

  wrap(value) {
    return value;
  },

  setState(updateFn = (current)=> current) {
    this._update = true;
    var nextState = updateFn.call(this, this.value);
    if (nextState !== this.value) {
      this.value = nextState;
      this.recompute();
      sendActionNotification(this, 'state', nextState);
    }
    return this.value;
  }
});

function sendActionNotification(helper, actionName, state) {
  var actionCallback = helper.options[Ember.String.dasherize(`on-${actionName}`)];
  Ember.sendEvent(helper, actionName, [state]);
  if (actionCallback && actionCallback.call) {
    actionCallback.call(null, state);
  }
}

{'fraction_non_alphanumeric': 0.1494295178505705, 'fraction_numerical': 0.0, 'mean_word_length': 2.973684210526316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1735975', 'n_tokens_mistral': 829, 'n_tokens_neox': 828, 'n_words': 175}