<commit_before>(function(root, factory){
    if (typeof define === 'function' && define.amd) {
        define(factory);
    } else if (typeof exports === 'object') {
        module.exports = factory();
    } else {
        root.microbar = factory();
    }
})(this, function(){
    var css = '.microbar{width: 100%;height: 2px;z-index: 9999;top:0;background-color: transparent;}'
            + '.microbar .mprogress{width: 0;height: 100%;background-color: #000000;}'
            + '.microbar .mprogress .mshadow{width: 1%;position: relative;height: 100%;float: right;}';
    function getEquivalentTime(speed){
        return (0.5 + Math.round(1/speed)).toString()+'s';
    }

    function isColor(color){
        var el = document.createElement('div');
        el.style.backgroundColor = color;
        if(el.style.backgroundColor.length == 0)
            throw new Error('Please check the color entered');
    }

    function transitionEndEventName () {
        var el = document.createElement('div'), transitions = { 'transition':'transitionend', 'OTransition':'otransitionend', 'MozTransition':'transitionend', 'WebkitTransition':'webkitTransitionEnd'};
        for(var i in transitions) {
            if (transitions.hasOwnProperty(i) && el.style[i] !== undefined)
                return transitions[i];
        }
        return null;
    }

    function addStyleSheet(){
        if(document.getElementById('microbarstyles') != undefined)
            return;
        var style = document.createElement('style');
        style.type = 'text/css', style.id = 'microbarstyles';
        if(style.styleSheet){
            style.styleSheet.cssText = css;
        }
        else{
            style.appendChild(document.createTextNode(css));
        }
        document.head.insertBefore(style, null);
    }

    function initialize(color, percentage, speed){
        addStyleSheet();isColor(color);
        var bar = document.createElement('div'), progress = document.createElement('div'), shadow = document.createElement('div'), time = getEquivalentTime(speed);
        bar.className = 'microbar';
        progress.classList.add('mprogress') , progress.style.backgroundColor = color, progress.style.width = percentage+'%', progress.style.transition = 'width '+time+' ease, opacity 0.3s ease';
        shadow.classList.add('mshadow'), shadow.style.boxShadow = "0 0 10px "+color;
        if(percentage == 0)
            progress.style.opacity = 0;
        progress.appendChild(shadow);
        bar.appendChild(progress);
        var transitionEnd = transitionEndEventName();
        if(transitionEnd == null)
            throw new Error('Your browser is not supported.');
        progress.addEventListener(transitionEnd, function(){
            var width = this.style.width;
            if(width == '100%')
                this.style.opacity = 0;
        });
        return {bar: bar, progress: progress, shadow: shadow};
    }

    return function microbar(args){
        args = args || {};
        if(args.hasOwnProperty('speed') && (typeof args.speed !== 'number' || args.speed > 10 || args.speed < 1))
            throw new Error('Speed should be an integer between 1 and 10.');
        if(args.hasOwnProperty('percentage') && (typeof args.percentage !== 'number' || args.percentage > 100 || args.percentage < 0))
            throw new Error('Percentage should be an integer between 0 and 100.');

        var percentage = args.percentage || 0,
            color = args.color || '#000000',
            speed = args.speed || 10;

        var divs = initialize(color, percentage, speed);
        var bar = divs['bar'], progress = divs['progress'], shadow = divs['shadow'];
        if(args.target) {
            bar.style.position = 'relative';
            document.getElementById(args.target).insertBefore(bar, document.getElementById(args.target).firstChild);
        }
        else {
            bar.style.position = 'fixed';
            document.getElementsByTagName('body')[0].appendChild(bar);
        }
        return {
            moveTo: function(p){
                if(typeof p !== 'number' || p > 100 || p < 0)
                    throw new Error('Percentage should be an integer between 0 and 100.');
                progress.style.opacity = 1;
                progress.style.width = p + '%';
            },
            getColor: function(){
                return color;
            },
            setColor: function(c){
                isColor(c);color = c;
                progress.style.backgroundColor = c;
                shadow.style.boxShadow = "0 0 10px "+c;
            },
            getSpeed: function(){
                return speed;
            },
            setSpeed: function(s){
                if(s > 10 || s < 1)
                    throw new RangeError('Speed should be an integer between 1 and 10.');
                speed = s;
                progress.style.transition = 'width '+getEquivalentTime(s);
            }
        };
    };
});
<commit_msg>Source Code moved to ES6<commit_after>class microbar {
  constructor(args = {}) {
    if (Object.prototype.hasOwnProperty.call(args, 'speed') &&
        (typeof args.speed !== 'number' || args.speed > 10 || args.speed < 1)) {
      throw new Error('Speed should be an integer between 1 and 10.');
    }
    if (Object.prototype.hasOwnProperty.call(args, 'percentage') &&
        (typeof args.percentage !== 'number' || args.percentage > 100 || args.percentage < 0)) {
      throw new Error('Percentage should be an integer between 0 and 100.');
    }

    this._percentage = args.percentage || 0;
    this._color = args.color || '#000000';
    this._speed = args.speed || 10;

    this._divs = this._initialize();

    this._bar = this._divs.bar;
    this._progress = this._divs.progress;
    this._shadow = this._divs.shadow;

    if (args.target) {
      this._bar.style.position = 'relative';

      document.getElementById(args.target).insertBefore(
        this._bar,
        document.getElementById(args.target).firstChild
      );
    } else {
      this._bar.style.position = 'fixed';

      document.getElementsByTagName('body')[0].appendChild(this._bar);
    }
  }

  _getEquivalentTime(speed) {
    const time = (0.5 + Math.round(1 / speed));
    return `${time}s`;
  }

  _isColor(color) {
    const el = document.createElement('div');
    el.style.backgroundColor = color;
    if (el.style.backgroundColor.length === 0) {
      return false;
    }
    return true;
  }

  _transitionEndEventName() {
    const el = document.createElement('div');
    const transitions = {
      transition: 'transitionend',
      OTransition: 'otransitionend',
      MozTransition: 'transitionend',
      WebkitTransition: 'webkitTransitionEnd'
    };

    for (const transition of Object.keys(transitions)) {
      if (Object.prototype.hasOwnProperty.call(transitions, transition) &&
          el.style[transition] !== undefined) {
        return transitions[transition];
      }
    }
    return null;
  }

  _addStyleSheet() {
    if (document.getElementById('microbarstyles') !== null) {
      return;
    }

    const style = document.createElement('style');
    style.type = 'text/css';
    style.id = 'microbarstyles';

    if (style.styleSheet) {
      style.styleSheet.cssText = microbar.css;
    } else {
      style.appendChild(document.createTextNode(microbar.css));
    }

    document.head.insertBefore(style, null);
  }

  _initialize() {
    this._addStyleSheet();
    if (!this._isColor(this._color)) {
      throw new Error('Please check the color entered');
    }

    const bar = document.createElement('div');
    const progress = document.createElement('div');
    const shadow = document.createElement('div');

    const time = this._getEquivalentTime(this._speed);

    bar.className = 'microbar';

    progress.classList.add('mprogress');
    progress.style.backgroundColor = this._color;
    progress.style.width = `${this._percentage}%`;
    progress.style.transition = `width ${time} ease, opacity 0.3s ease`;

    shadow.classList.add('mshadow');
    shadow.style.boxShadow = `0 0 10px ${this._color}`;

    if (this._percentage === 0) {
      progress.style.opacity = 0;
    }

    progress.appendChild(shadow);
    bar.appendChild(progress);

    const transitionEnd = this._transitionEndEventName();

    if (transitionEnd === null) {
      throw new Error('Your browser is not supported.');
    }

    progress.addEventListener(transitionEnd, this._transitionEnd);

    return {
      bar,
      progress,
      shadow
    };
  }

  _transitionEnd() {
    const width = this.style.width;
    if (width === '100%') {
      this.style.opacity = 0;
    }
  }

  moveTo(point) {
    if (typeof point !== 'number' || point > 100 || point < 0) {
      throw new Error('Percentage should be an integer between 0 and 100.');
    }

    this._progress.style.opacity = 1;
    this._progress.style.width = `${point}%`;
  }

  get color() {
    return this._color;
  }

  set color(color) {
    if (!this._isColor(color)) {
      throw new Error('Please check the color entered');
    }
    this._color = color;

    this._progress.style.backgroundColor = color;
    this._shadow.style.boxShadow = `0 0 10px ${color}`;
  }

  get speed() {
    return this._speed;
  }

  set speed(speed) {
    if (speed > 10 || speed < 1) {
      throw new RangeError('Speed should be an integer between 1 and 10.');
    }

    this._speed = speed;

    const time = this._getEquivalentTime(speed);
    this._progress.style.transition = `width ${time}`;
  }
}

microbar.css = '.microbar{width: 100%;height: 2px;z-index: 9999;top:0;background-color: transparent;}'
             + '.microbar .mprogress{width: 0;height: 100%;background-color: #000000;}'
             + '.microbar .mprogress .mshadow{width: 1%;position: relative;height: 100%;float: right;}';

module.exports = microbar;

{'fraction_non_alphanumeric': 0.1398884946781551, 'fraction_numerical': 0.016725798276735936, 'mean_word_length': 2.5210563882940757, 'pattern_counts': {'":': 0, '<': 11, '<?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': '6364100', 'n_tokens_mistral': 2947, 'n_tokens_neox': 2753, 'n_words': 631}