<commit_before>(function($) {
  var revert = (function() {
    var revert_action_type_map = {'remove': 'add', 'add': 'remove', 'edit': 'edit'};
    var map = {
      remove: function(action) {
        var story = wikimate.utils.replay(this.wikimate('journal'));
        var item = story.itemById(action.id);
        var index = story.indexOf(item);
        var after = index === 0 ? null : story[index - 1].id;
        return {id: action.id, type: 'add', item: item, after: after};
      },
      add: function(action) {
        return {id: action.id, type: 'remove', item: action.item, after: action.after};
      },
      edit: function(action) {
        var story = wikimate.utils.replay(this.wikimate('journal'));
        var prev = story.itemById(action.id);
        return {id: action.id, type: 'edit', item: $.extend({}, prev)};
      },
      move: function(action) {
        var story = wikimate.utils.replay(this.wikimate('journal'));
        return {id: action.id, type: 'move', order: _.pluck(story, 'id')};
      }
    };
    return function(action) {
      return map[action.type].apply(this, [action]);
    };
  })();

  wikimate.fn.undo = function() {
    var action = this.find('.wikimate-journal').journal('pop');
    if (!action) {
      return;
    }
    this.find('.wikimate-story').story('execute', revert.apply(this, [action]));
    return action;
  };
})(jQuery);<commit_msg>changed to use switch cases, clean code<commit_after>(function($) {
  function revert(action) {
    var story;
    switch(action.type) {
      case 'remove':
        story = wikimate.utils.replay(this.wikimate('journal'));
        var item = story.itemById(action.id);
        var index = story.indexOf(item);
        var after = index === 0 ? null : story[index - 1].id;
        return {id: action.id, type: 'add', item: item, after: after};
      case 'add':
        return {id: action.id, type: 'remove', item: action.item};
      case 'edit':
        story = wikimate.utils.replay(this.wikimate('journal'));
        var prev = story.itemById(action.id);
        return {id: action.id, type: 'edit', item: $.extend({}, prev)};
      case 'move':
        story = wikimate.utils.replay(this.wikimate('journal'));
        return {id: action.id, type: 'move', order: _.pluck(story, 'id')};
      default:
        throw "Unknown action type: " + action.type;
    }
  }

  wikimate.fn.undo = function() {
    var action = this.find('.wikimate-journal').journal('pop');
    if (!action) {
      return;
    }
    this.find('.wikimate-story').story('execute', revert.apply(this, [action]));
    return action;
  };
})(jQuery);
{'fraction_non_alphanumeric': 0.1801526717557252, 'fraction_numerical': 0.0015267175572519084, 'mean_word_length': 2.771223021582734, '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': '1250044', 'n_tokens_mistral': 839, 'n_tokens_neox': 825, 'n_words': 193}