<commit_before>function inertia(gun) {
    var _decreased = null, spd = new Speed;
    var _decrease = function () {
        if (
            decrease instanceof Function
        ) {
            var res = decrease();
            if (res === false) return;
            _decreased = res;
            smooth_timer = requestAnimationFrame(_decrease);
        }
    };
    var _cancel = function () {
        cancelAnimationFrame(smooth_timer);
        _decreased = null;
        decrease = null;
    }
    var smooth = function () {
        var args = spd.read();
        if (args.filter(a => Math.abs(a) > .1).length === 0) {
            spd.reset();
            smooth_timer = requestAnimationFrame(_decrease);
            return;
        }
        var res = gun.apply(that, args);
        if (false === res) {
            spd.reset();
        }
        smooth_timer = requestAnimationFrame(smooth);
    };
    var spd, smooth_timer, that, decrease;
    var train = function () {
        _cancel();
        var args = [].slice.call(arguments, 0, arguments.length);
        spd.write(args);
        gun.apply(this, args);
        that = this;
    };
    train.smooth = function (d) {
        _cancel();
        decrease = d;
        smooth_timer = requestAnimationFrame(smooth);
    };
    train.reset = function () {
        _cancel();
        spd.reset();
    };
    return train;

}
class Speed extends Array {
    cache = [];
    stamp = 0;
    static now() {
        return performance.now ? performance.now() : Date.now();
    }
    static inertia = inertia;
    reset() {
        this.cache.splice(0, this.cache.length);
        this.splice(0, this.length);
        this.stamp = 0;
    }
    write(values, stamp = Speed.now()) {
        if (values.length !== this.length) this.reset();
        this.cache.push(values, stamp);
        if (this.cache.length > 20) this.cache.splice(0, 12);
        var start = Math.max(this.cache.length - 6, 0);
        var s = values.slice(0, values.length), t = this.cache[this.cache.length - 1] - this.cache[start + 1] + 20;
        for (var cx = start, dx = this.cache.length - 2; cx < dx; cx++) {
            var values = this.cache[cx++];
            for (var cy = 0, dy = values.length; cy < dy; cy++) {
                var v = values[cy];
                if (!s[cy]) s[cy] = 0;
                s[cy] += v;
            }
        }
        for (var cx = 0, dx = s.length; cx < dx; cx++) {
            this[cx] = s[cx] / t;
        }
    }
    read(now = Speed.now()) {
        var stamp = this.cache[this.cache.length - 1];
        var values = this.slice(0);
        var deltat = now - stamp;
        var ratio = Math.pow(0.99999, Math.pow(1.01, deltat));
        console.log(ratio)
        if (this.stamp) ratio *= now - this.stamp;
        this.stamp = now;
        for (var cx = 0, dx = values.length; cx < dx; cx++) {
            values[cx] *= ratio;
        }
        return values;
    }<commit_msg>删除log<commit_after>function inertia(gun) {
    var _decreased = null, spd = new Speed;
    var _decrease = function () {
        if (
            decrease instanceof Function
        ) {
            var res = decrease();
            if (res === false) return;
            _decreased = res;
            smooth_timer = requestAnimationFrame(_decrease);
        }
    };
    var _cancel = function () {
        cancelAnimationFrame(smooth_timer);
        _decreased = null;
        decrease = null;
    }
    var smooth = function () {
        var args = spd.read();
        if (args.filter(a => Math.abs(a) > .1).length === 0) {
            spd.reset();
            smooth_timer = requestAnimationFrame(_decrease);
            return;
        }
        var res = gun.apply(that, args);
        if (false === res) {
            spd.reset();
        }
        smooth_timer = requestAnimationFrame(smooth);
    };
    var spd, smooth_timer, that, decrease;
    var train = function () {
        _cancel();
        var args = [].slice.call(arguments, 0, arguments.length);
        spd.write(args);
        gun.apply(this, args);
        that = this;
    };
    train.smooth = function (d) {
        _cancel();
        decrease = d;
        smooth_timer = requestAnimationFrame(smooth);
    };
    train.reset = function () {
        _cancel();
        spd.reset();
    };
    return train;

}
class Speed extends Array {
    cache = [];
    stamp = 0;
    static now() {
        return performance.now ? performance.now() : Date.now();
    }
    static inertia = inertia;
    reset() {
        this.cache.splice(0, this.cache.length);
        this.splice(0, this.length);
        this.stamp = 0;
    }
    write(values, stamp = Speed.now()) {
        if (values.length !== this.length) this.reset();
        this.cache.push(values, stamp);
        if (this.cache.length > 20) this.cache.splice(0, 12);
        var start = Math.max(this.cache.length - 6, 0);
        var s = values.slice(0, values.length), t = this.cache[this.cache.length - 1] - this.cache[start + 1] + 20;
        for (var cx = start, dx = this.cache.length - 2; cx < dx; cx++) {
            var values = this.cache[cx++];
            for (var cy = 0, dy = values.length; cy < dy; cy++) {
                var v = values[cy];
                if (!s[cy]) s[cy] = 0;
                s[cy] += v;
            }
        }
        for (var cx = 0, dx = s.length; cx < dx; cx++) {
            this[cx] = s[cx] / t;
        }
    }
    read(now = Speed.now()) {
        var stamp = this.cache[this.cache.length - 1];
        var values = this.slice(0);
        var deltat = now - stamp;
        var ratio = Math.pow(0.99999, Math.pow(1.01, deltat));
        if (this.stamp) ratio *= now - this.stamp;
        this.stamp = now;
        for (var cx = 0, dx = values.length; cx < dx; cx++) {
            values[cx] *= ratio;
        }
        return values;
    }
{'fraction_non_alphanumeric': 0.14519706534721039, 'fraction_numerical': 0.011943354376386283, 'mean_word_length': 1.665757162346521, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '7418251', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1810, 'n_words': 451}