<commit_before>var Regions = (function(root, undefined) {
  "use strict";
  // Private
  var _this;
  var toArray = Array.prototype.slice;
  var defaults = {
    version: '0.1'
  };
  var listener = window.addEventListener || window.attachEvent;

  function init(opts) {

    // Return if on IE
    if('attachEvent' in window) {
      return false;
    }

    _this = this;
    _this.elems = {
      containers: [],
      movers: []
    };
    opts = opts || {};
    var options = helpers.extend(defaults, opts);

    addListeners();
  };

  function addListeners() {
    // Listen
    listener('DOMContentLoaded', setElems);
    listener('resize', resizeHandler);
  }

  function setElems() {
    var nodeList = toArray.call( document.querySelectorAll('[region-container], [region-flow-into]') ) || [];
    for(var i in nodeList) {

      var node = nodeList[i];
      var attrs = [];
      // Loop through attributes of node and store in key-value
      toArray.call(node.attributes).forEach(function(attr) {
        attrs[attr.name] = attr.value;
      });

      if ( typeof attrs['region-flow-into'] === 'undefined' ) {
        _this.elems['containers'][ attrs['region-container'] ] = node;
      } else {
        _this.elems['movers'].push({
          node:             node,
          breakPoint:       attrs['region-breakpoint'],
          flowInto:         attrs['region-flow-into'],
          isMoved:          false,
          origPrevSibling:  node.previousElementSibling,
          origParent:       node.parentNode,
          priority:         i
        });
      }
    }
    // Set init positions
    resizeHandler();
  };

  function resizeHandler() {
    var elems = _this.elems['movers'];
    var width = window.innerWidth;
    var containers = _this.elems['containers']

    for(var i in elems) {
      var elem = elems[i];
      var breakPoint = parseInt( elem.breakPoint, 10);

      if( !elem.isMoved && width <= breakPoint ) {
        elem.isMoved = true;
        helpers.appendChild(containers[elem.flowInto], elem.node);

      } else if( elem.isMoved && width > breakPoint ) {
        elem.isMoved = false;
        if(elem.origPrevSibling) {
          helpers.insertAfter(elem.origPrevSibling, elem.node);
        } else {
          helpers.prependChild(elem.origParent, elem.node);
        }
      }
    }
  }

  // Helpers
  var helpers = {
    /*
    * Extends orig obj with ext obj - shallow copy
    */
    extend: function(orig, ext) {
      if(typeof orig !== 'object' || typeof ext !== 'object')
        throw new Error('Can only extend objects');

      for(var key in ext) {
        orig[key] = ext[key];<commit_msg>Don't throw error<commit_after>var Regions = (function(root, undefined) {
  "use strict";
  // Private
  var _this;
  var toArray = Array.prototype.slice;
  var defaults = {
    version: '0.1'
  };
  var listener = window.addEventListener || window.attachEvent;

  function init(opts) {

    // Return if on IE
    if('attachEvent' in window) {
      return false;
    }

    _this = this;
    _this.elems = {
      containers: [],
      movers: []
    };
    opts = opts || {};
    var options = helpers.extend(defaults, opts);

    addListeners();
  };

  function addListeners() {
    // Listen
    listener('DOMContentLoaded', setElems);
    listener('resize', resizeHandler);
  }

  function setElems() {
    var nodeList = toArray.call( document.querySelectorAll('[region-container], [region-flow-into]') ) || [];
    for(var i in nodeList) {

      var node = nodeList[i];
      var attrs = [];
      // Loop through attributes of node and store in key-value
      toArray.call(node.attributes).forEach(function(attr) {
        attrs[attr.name] = attr.value;
      });

      if ( typeof attrs['region-flow-into'] === 'undefined' ) {
        _this.elems['containers'][ attrs['region-container'] ] = node;
      } else {
        _this.elems['movers'].push({
          node:             node,
          breakPoint:       attrs['region-breakpoint'],
          flowInto:         attrs['region-flow-into'],
          isMoved:          false,
          origPrevSibling:  node.previousElementSibling,
          origParent:       node.parentNode,
          priority:         i
        });
      }
    }
    // Set init positions
    resizeHandler();
  };

  function resizeHandler() {
    var elems = _this.elems['movers'];
    var width = window.innerWidth;
    var containers = _this.elems['containers']

    for(var i in elems) {
      var elem = elems[i];
      var breakPoint = parseInt( elem.breakPoint, 10);

      if( !elem.isMoved && width <= breakPoint ) {
        elem.isMoved = true;
        helpers.appendChild(containers[elem.flowInto], elem.node);

      } else if( elem.isMoved && width > breakPoint ) {
        elem.isMoved = false;
        if(elem.origPrevSibling) {
          helpers.insertAfter(elem.origPrevSibling, elem.node);
        } else {
          helpers.prependChild(elem.origParent, elem.node);
        }
      }
    }
  }

  // Helpers
  var helpers = {
    /*
    * Extends orig obj with ext obj - shallow copy
    */
    extend: function(orig, ext) {
      if(typeof orig !== 'object' || typeof ext !== 'object') {
        console.log('Can only extend objects. Defaults are being used');
        return;
      }

      for(var key in ext) {
        orig[key] = ext[key];
{'fraction_non_alphanumeric': 0.13482726423902894, 'fraction_numerical': 0.0014939309056956115, 'mean_word_length': 2.169230769230769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2856333', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1627, 'n_words': 366}