<commit_before>pc.extend(pc, (function () {

    var CURVE_LINEAR = 0;
    var CURVE_SMOOTHSTEP = 1;
    var CURVE_CATMULL = 2;
    var CURVE_CARDINAL = 3;

    var Curve = function (data) {
        this.keys = [];
        this.type = CURVE_SMOOTHSTEP;

        this.tension = 0.5; // used for CURVE_CARDINAL

        if (data) {
            for (var i = 0; i < data.length - 1; i += 2) {
                this.keys.push([data[i], data[i+1]]);
            }
        }

        this.sort();
    };

    Curve.prototype = {
        /**
        * @private
        * @function
        * @name pc.Curve#add
        * @description Add new key
        * @param {Number} time Time to add new key
        * @param {Number} value Value of new key
        * @returns {Array} [time, value] pair
        */
        add: function (time, value) {
            var keys = this.keys;
            var len = keys.length;
            var i = 0;

            for (; i < len; i++) {
                if (keys[i][0] > time) {
                    break;
                }
            }

            var key = [time, value];
            this.keys.splice(i, 0, key);
            return key;
        },

        /**
        * @private
        * @function
        * @name pc.Curve#get
        * @description Return a specific key
        * @param {Number} index The index of the key to return
        * @returns {Array} [time, value] pair
        */
        get: function (index) {
            return this.keys[index];
        },

        /**
        * @private
        * @function
        * @name pc.Curve#sort
        * @description Sort keys by time
        */
        sort: function () {
            this.keys.sort(function (a, b) {
                return a[0] - b[0];
            });
        },

        /**
        * @private
        * @function
        * @name pc.Curve#value
        * @description return value interpolated at time
        * @param {Number} time The time at which to calculate the value
        * @return {Number} The interpolated value
        */
        value: function (time) {
            var keys = this.keys;

            var leftTime = 0;
            var leftValue = keys.length ? keys[0][1] : 0;

            var rightTime = 1;
            var rightValue = 0;

            for (var i = 0, len = keys.length; i < len; i++) {
                // early exit check
                if (keys[i][0] === time) {
                    return keys[i][1];
                }

                rightValue = keys[i][1];

                if (time < keys[i][0]) {
                    rightTime = keys[i][0];
                    break;
                }

                leftTime = keys[i][0];
                leftValue = keys[i][1];
            }

            // Clamp values before first and after last key
            if (time < keys[0][0]) {
                return keys[0][1];
            } else if (time > keys[keys.length-1][0]) {
                return keys[keys.length-1][1];
            }

            var div = rightTime - leftTime;
            var interpolation = (div === 0 ? 0 : (time - leftTime) / div);
<commit_msg>[FIX] pc.Curve with no keys<commit_after>pc.extend(pc, (function () {

    var CURVE_LINEAR = 0;
    var CURVE_SMOOTHSTEP = 1;
    var CURVE_CATMULL = 2;
    var CURVE_CARDINAL = 3;

    var Curve = function (data) {
        this.keys = [];
        this.type = CURVE_SMOOTHSTEP;

        this.tension = 0.5; // used for CURVE_CARDINAL

        if (data) {
            for (var i = 0; i < data.length - 1; i += 2) {
                this.keys.push([data[i], data[i+1]]);
            }
        }

        this.sort();
    };

    Curve.prototype = {
        /**
        * @private
        * @function
        * @name pc.Curve#add
        * @description Add new key
        * @param {Number} time Time to add new key
        * @param {Number} value Value of new key
        * @returns {Array} [time, value] pair
        */
        add: function (time, value) {
            var keys = this.keys;
            var len = keys.length;
            var i = 0;

            for (; i < len; i++) {
                if (keys[i][0] > time) {
                    break;
                }
            }

            var key = [time, value];
            this.keys.splice(i, 0, key);
            return key;
        },

        /**
        * @private
        * @function
        * @name pc.Curve#get
        * @description Return a specific key
        * @param {Number} index The index of the key to return
        * @returns {Array} [time, value] pair
        */
        get: function (index) {
            return this.keys[index];
        },

        /**
        * @private
        * @function
        * @name pc.Curve#sort
        * @description Sort keys by time
        */
        sort: function () {
            this.keys.sort(function (a, b) {
                return a[0] - b[0];
            });
        },

        /**
        * @private
        * @function
        * @name pc.Curve#value
        * @description return value interpolated at time
        * @param {Number} time The time at which to calculate the value
        * @return {Number} The interpolated value
        */
        value: function (time) {
            var keys = this.keys;

            // no keys
            if (!keys.length) {
                return 0;
            }

            // Clamp values before first and after last key
            if (time < keys[0][0]) {
                return keys[0][1];
            } else if (time > keys[keys.length-1][0]) {
                return keys[keys.length-1][1];
            }

            var leftTime = 0;
            var leftValue = keys.length ? keys[0][1] : 0;

            var rightTime = 1;
            var rightValue = 0;

            for (var i = 0, len = keys.length; i < len; i++) {
                // early exit check
                if (keys[i][0] === time) {
                    return keys[i][1];
                }

                rightValue = keys[i][1];

                if (time < keys[i][0]) {
                    rightTime = keys[i][0];
                    break;
                }

                leftTime = keys[i][0];
                leftValue = keys[i][1];
            }

            var div = rightTime - leftTime;
            var interpolation = (div === 0 ? 0 : (time - leftTime) / div);

{'fraction_non_alphanumeric': 0.1231838281743525, 'fraction_numerical': 0.012476310802274163, 'mean_word_length': 1.1636487871540826, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '734096', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1804, 'n_words': 512}