<commit_before>var postcss = require("postcss");

(function () {

  "use strict";

  module.exports = postcss.plugin("postcss-prefixwrap", function (prefixSelector, options) {

    options = options || {};

    function invalidCSSSelectors(cssSelector) {
      return cssSelector !== null;
    }

    function prefixWrapCSSSelector(cssSelector) {
      var isRootTag = /^(body|html).*$/;
      var anyWhitespaceAtBeginningOrEnd = /(^\s*|\s*$)/g;
      var prefixRootTags = options.prefixRootTags;

      // Remove any whitespace characters before or after our selector.
      var cleanSelector = cssSelector.replace(anyWhitespaceAtBeginningOrEnd, "");

      // Selector part may just be a blank line, in this case bail out.
      if (cleanSelector === "") {
        return null;
      }

      // Anything other than a root tag is always prefixed.
      if (!cleanSelector.match(isRootTag)) {
        return prefixSelector + " " + cleanSelector;
      }

      // Handle special case where root tags should be converted into classes rather than being replaced.
      if (prefixRootTags) {
        return prefixSelector + " ." + cleanSelector;
      }

      // HTML and Body elements cannot be contained within our container so lets extract their styles.
      return cleanSelector.replace(/^(body|html)/, prefixSelector);
    }

    function prefixWrapCSSRule(cssRule) {
      var isPrefixSelector = new RegExp("^\s*" + prefixSelector + ".*$");

      // We have found our prefix selector, we just want to leave it as it is already.
      if (!cssRule.selector.match(isPrefixSelector)) {
        cssRule.selector = cssRule.selector
          .split(",")
          .map(prefixWrapCSSSelector)
          .filter(invalidCSSSelectors)
          .join(", ");
      }
    }

    return function (css) {
      css.walkRules(prefixWrapCSSRule);
    };
  });
}());<commit_msg>Refactoring to avoid behaviour all existing in module exports.<commit_after>var postcss = require("postcss");

(function () {

  "use strict";

  function PostCSSPrefixWrap(prefixSelector, options) {
    this.anyWhitespaceAtBeginningOrEnd = /(^\s*|\s*$)/g;
    this.isPrefixSelector = new RegExp("^\s*" + prefixSelector + ".*$");
    this.isRootTag = /^(body|html).*$/;
    this.prefixRootTags = options !== undefined && options.hasOwnProperty("prefixRootTags") ? options.prefixRootTags : false;
    this.prefixSelector = prefixSelector;
  }

  PostCSSPrefixWrap.prototype.invalidCSSSelectors = function (cssSelector) {
    return cssSelector !== null;
  };

  PostCSSPrefixWrap.prototype.prefixWrapCSSSelector = function (cssSelector) {
    var that = this;

    var cleanSelector = cssSelector.replace(that.anyWhitespaceAtBeginningOrEnd, "");

    if (cleanSelector === "") {
      return null;
    }

    // Anything other than a root tag is always prefixed.
    if (!cleanSelector.match(that.isRootTag)) {
      return that.prefixSelector + " " + cleanSelector;
    }

    // Handle special case where root tags should be converted into classes rather than being replaced.
    if (that.prefixRootTags) {
      return that.prefixSelector + " ." + cleanSelector;
    }

    // HTML and Body elements cannot be contained within our container so lets extract their styles.
    return cleanSelector.replace(/^(body|html)/, that.prefixSelector);
  };

  PostCSSPrefixWrap.prototype.prefixWrapCSSRule = function (cssRule) {
    var that = this;

    // We have found our prefix selector, we just want to leave it as it is already.
    if (!cssRule.selector.match(that.isPrefixSelector)) {
      cssRule.selector = cssRule.selector
        .split(",")
        .map(function (cssSelector) {
          return that.prefixWrapCSSSelector(cssSelector);
        })
        .filter(that.invalidCSSSelectors)
        .join(", ");
    }
  };

  PostCSSPrefixWrap.prototype.asPlugin = function () {
    var that = this;

    return function (css) {
      css.walkRules(function (cssRule) {
        that.prefixWrapCSSRule(cssRule);
      });
    };
  };

  module.exports = postcss.plugin("postcss-prefixwrap", function (prefixSelector, options) {
    return new PostCSSPrefixWrap(prefixSelector, options).asPlugin();
  });

}());
{'fraction_non_alphanumeric': 0.11830783938814532, 'fraction_numerical': 0.0, 'mean_word_length': 3.0356798457087755, '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': '3247519', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1146, 'n_words': 304}