<commit_before>(function (undefined) {

    var Duration = function(duration){
        if (duration) {
            this.parse(duration);
        }
    };

    Duration.prototype = {
        units: {
            week: {labels: ['week', 'weeks', 'w'], multiplier: 7*24*60*60},
            day: {labels: ['day', 'days', 'd'], multiplier: 24*60*60},
            hour: {labels: ['hour', 'hours', 'h'], multiplier: 60*60},
            minute: {labels: ['minute', 'minutes', 'min', 'mins', 'm'], multiplier: 60},
            second: {labels: ['second', 'seconds', 'sec', 'secs', 's'], multiplier: 1}
        },
        add: function(number, unit) {
            for (unitType in this.units) {
                this.units[unitType].labels.forEach(function(label){
                    if (unit === label) {
                        this._seconds += number * this.units[unitType].multiplier;
                        return;
                    }
                }, this);
            }

            return this;
        },
        parse: function(duration) {
            this._seconds = 0;
            var times = duration.match(/(\d*\.?\d+)\s*([a-zA-Z]+)/g);

            times.forEach(function(time){
                var timePart = /(\d*\.?\d+)\s*([a-zA-Z]+)/i.exec(time);
                var unit = timePart[2].toLowerCase();
                var number = timePart[1];
                this.add(number, unit);
            }, this);

            return this;
        },

        weeks: function() {
            return this._seconds / this.units.week.multiplier;
        },

        days: function() {
            return this._seconds / this.units.day.multiplier;
        },

        hours: function() {
            return this._seconds / this.units.hour.multiplier;
        },

        minutes: function() {
            return this._seconds / this.units.minute.multiplier;
        },

        seconds: function() {
            return this._seconds;
        }
    };


    /************************************
        Exposing Duration
    ************************************/


    // CommonJS module is defined
    var hasModule = (typeof module !== 'undefined' && module.exports)
    if (hasModule) {
        module.exports = Duration;
    }
    /*global ender:false */
    if (typeof ender === 'undefined') {
        // here, `this` means `window` in the browser, or `global` on the server
        // add `Duration` as a global object via a string identifier,
        // for Closure Compiler "advanced" mode
        this['Duration'] = Duration;
    }
    /*global define:false */
    if (typeof define === "function" && define.amd) {
        define("Duration", [], function () {
            return Duration;
        });
    }
}).call(this);<commit_msg>remove .forEach for IE8 compatibility<commit_after>(function (undefined) {

    var Duration = function(duration){
        if (duration) {
            this.parse(duration);
        }
    };

    Duration.prototype = {
        units: {
            week: {labels: ['week', 'weeks', 'w'], multiplier: 7*24*60*60},
            day: {labels: ['day', 'days', 'd'], multiplier: 24*60*60},
            hour: {labels: ['hour', 'hours', 'h'], multiplier: 60*60},
            minute: {labels: ['minute', 'minutes', 'min', 'mins', 'm'], multiplier: 60},
            second: {labels: ['second', 'seconds', 'sec', 'secs', 's'], multiplier: 1}
        },
        add: function(number, unit) {
            for (unitType in this.units) {
                var labels = this.units[unitType].labels;
                for (var i = 0; i < labels.length; i++) {
                    if (unit === labels[i]) {
                        this._seconds += number * this.units[unitType].multiplier;
                        return;
                    }
                }
            }

            return this;
        },
        parse: function(duration) {
            this._seconds = 0;
            var times = duration.match(/(\d*\.?\d+)\s*([a-zA-Z]+)/g);

            for (var i = 0; i < times.length; i++) {
                var timePart = /(\d*\.?\d+)\s*([a-zA-Z]+)/i.exec(times[i]);
                var unit = timePart[2].toLowerCase();
                var number = timePart[1];
                this.add(number, unit);
            }

            return this;
        },

        weeks: function() {
            return this._seconds / this.units.week.multiplier;
        },

        days: function() {
            return this._seconds / this.units.day.multiplier;
        },

        hours: function() {
            return this._seconds / this.units.hour.multiplier;
        },

        minutes: function() {
            return this._seconds / this.units.minute.multiplier;
        },

        seconds: function() {
            return this._seconds;
        }
    };


    /************************************
        Exposing Duration
    ************************************/


    // CommonJS module is defined
    var hasModule = (typeof module !== 'undefined' && module.exports)
    if (hasModule) {
        module.exports = Duration;
    }
    /*global ender:false */
    if (typeof ender === 'undefined') {
        // here, `this` means `window` in the browser, or `global` on the server
        // add `Duration` as a global object via a string identifier,
        // for Closure Compiler "advanced" mode
        this['Duration'] = Duration;
    }
    /*global define:false */
    if (typeof define === "function" && define.amd) {
        define("Duration", [], function () {
            return Duration;
        });
    }
}).call(this);
{'fraction_non_alphanumeric': 0.17637540453074432, 'fraction_numerical': 0.008809780654440848, 'mean_word_length': 1.6591778202676863, 'pattern_counts': {'":': 0, '<': 5, '<?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': '854165', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1497, 'n_words': 368}