<commit_before>(function($) {
  $.decorators = {};

  $.fn.decorator = function(options) {
    options = $.extend({}, options);
    options.decoratorIdentifier = "data-decorator";
    options.elementSelector = options.elementSelector || '[' + options.decoratorIdentifier + ']';

    var decoratorMethods = function(decoree){
      var _hashConfig = (function() {
        var _rawAttributeData = $(decoree).attr(options.decoratorIdentifier);
        var result = {};

        try {
          var _attributeData = eval( "({" + _rawAttributeData + "})" );
        } catch(e) {
          throw("Decorator attributes are invalid. It should be as 'decoratorName: config'. 'config' is a JSON. \n"
              + "Original error message: \n" + e.message );
        }

        $.each(_attributeData, function(key, value) {
          result['decoratorType'] = key;
          result['decoratorConfig'] = value;
        });
        return result;
      })()

      var type = function() { return _hashConfig.decoratorType };
      var config = function() { return _hashConfig.decoratorConfig };

      function wrapper() {
        var findFakeDiv = function() {
          var a = $(decoree).next('div[data-decorator-wrapper]');
          if (a.length == 0) {
            return false;
          } else {
            return a;
          }
        };
        var createFakeDiv = function() {
          var fakeDiv = $(document.createElement('div'));
          fakeDiv.attr({
            'data-decorator-wrapper': true,
            'class': 'decoratorWrapper'
          });
          $(decoree).after(fakeDiv);
          return fakeDiv;
        };
        return findFakeDiv() || createFakeDiv();
      };

      function decoratorConverter() {
        var converterPlugin = $.decorators[type()];

        if (converterPlugin === undefined) {
          throw "Undefined decorator extention '" + name + "'. "
              + "Please, provide 'jquery.decorator.'" + name + "' plugin. "
              + "See https://github.com/aratak/jquery.decorator/ for details."
        }

        return converterPlugin.call(decoree);
      };

      function init() {
        $.extend(decoree, {
          isDecoree: true,
          type: type(),
          config: config(),
          wrapper: wrapper,
        });
        return decoratorConverter();
      };

      return init();
    }

    return this.each(function() {
      $(this).find(options.elementSelector).each(function() {
        if(!$.isFunction(this.isDecoree)) {
          decoratorMethods(this);
        }
      });
    });
  }
})(jQuery);
<commit_msg>isDecoree is not a function yet. This is a flag.<commit_after>(function($) {
  $.decorators = {};

  $.fn.decorator = function(options) {
    options = $.extend({}, options);
    options.decoratorIdentifier = "data-decorator";
    options.elementSelector = options.elementSelector || '[' + options.decoratorIdentifier + ']';

    var decoratorMethods = function(decoree){
      var _hashConfig = (function() {
        var _rawAttributeData = $(decoree).attr(options.decoratorIdentifier);
        var result = {};

        try {
          var _attributeData = eval( "({" + _rawAttributeData + "})" );
        } catch(e) {
          throw("Decorator attributes are invalid. It should be as 'decoratorName: config'. 'config' is a JSON. \n"
              + "Original error message: \n" + e.message );
        }

        $.each(_attributeData, function(key, value) {
          result['decoratorType'] = key;
          result['decoratorConfig'] = value;
        });
        return result;
      })()

      var type = function() { return _hashConfig.decoratorType };
      var config = function() { return _hashConfig.decoratorConfig };

      function wrapper() {
        var findFakeDiv = function() {
          var a = $(decoree).next('div[data-decorator-wrapper]');
          if (a.length == 0) {
            return false;
          } else {
            return a;
          }
        };
        var createFakeDiv = function() {
          var fakeDiv = $(document.createElement('div'));
          fakeDiv.attr({
            'data-decorator-wrapper': true,
            'class': 'decoratorWrapper'
          });
          $(decoree).after(fakeDiv);
          return fakeDiv;
        };
        return findFakeDiv() || createFakeDiv();
      };

      function decoratorConverter() {
        var converterPlugin = $.decorators[type()];

        if (converterPlugin === undefined) {
          throw "Undefined decorator extention '" + name + "'. "
              + "Please, provide 'jquery.decorator.'" + name + "' plugin. "
              + "See https://github.com/aratak/jquery.decorator/ for details."
        }

        return converterPlugin.call(decoree);
      };

      function init() {
        $.extend(decoree, {
          isDecoree: true,
          type: type(),
          config: config(),
          wrapper: wrapper,
        });
        return decoratorConverter();
      };

      return init();
    }

    return this.each(function() {
      $(this).find(options.elementSelector).each(function() {
        if (!this.isDecoree) {
          decoratorMethods(this);
        }
      });
    });
  }
})(jQuery);


{'fraction_non_alphanumeric': 0.14288457845208374, 'fraction_numerical': 0.0003840983291722681, 'mean_word_length': 1.9879518072289157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7444184', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1411, 'n_words': 302}