<commit_before>/*
    update.js <https://github.com/davidfig/update>
    License: MIT license <https://github.com/davidfig/update/license>
    Author: <NAME>
    Copyright (c) 2016 YOPEY YOPEY LLC
*/

var list = [];
var FPS = 60;
var FPSActual;
var pause = false;
var pauseRegistrations = [];
var pauseElapsed = 0;

var startTime = 0;
var frameNumber = 0;
var lastUpdate = 0;
var lastFPS = '--';

var tolerance = 1;

var maxChange = 100;

var panels = {fps: null, meter: null, percent: null};
var percentageList = [];
var lastCount;

var DEBUG = false;
var COUNT = false;
var PERCENT = false;
var FPS = false;

// this is the number of entries to use in a rolling average to smooth the debug percentages
var rollingAverage = 500;

/**
 * must call Update.init before using Update
 * @param {boolean} debug - whether to turn on debug support (requires github.com/davidfig/debug)
 * @param {boolean=false|string} count - show debug counts (can supply side for panel, e.g., 'topleft')
 * @param {boolean=false|string} percent - show debug percentage
 * @param {boolean=false|string} FPS - show debug FPS
 */
function init(options)
{
    options = options || {};
    checkVisibility();
    FPSActual = 1000 / FPS;
    if (options.debug)
    {
        DEBUG = true;
        COUNT = options.count;
        PERCENT = options.percent;
        FPS = options.FPS;
        debugInit();
    }
}

// register functions to call after Update pauses or resumes
function registerPause(pause, resume)
{
    pauseRegistrations.push({ pause: pause, resume: resume});
}

function pauseGame()
{
    if (pause !== true)
    {
        pause = true;
        pauseElapsed = performance.now() - lastUpdate;
        updateOff = false;
        if (DEBUG)
        {
            debugPause();
        }
        for (var i = 0; i < pauseRegistrations.length; i++)
        {
            pauseRegistrations[i].pause();
        }
    }
}

function resumeGame()
{
    if (pause === true)
    {
        pause = false;
        lastUpdate = performance.now() - pauseElapsed;
        fpsReset();
        for (var i = 0; i < pauseRegistrations.length; i++)
        {
            pauseRegistrations[i].resume();
        }
        if (updateOff === true)
        {
            update();
        }
    }
}

function fpsReset()
{
    startTime = 0;
    frameNumber = 0;
    lastUpdate = 0;
    lastFPS = '--';
}

function updateOther(elapsed)
{
    var i = 0, _i = list.length;
    var total = 0, other = 0, updates = [], count = 0;
    while (i < _i)
    {
        var update = list[i++];
        if (update.pause)
        {
            continue;
        }
        if (update.duration !== 0)
        {
            update.elapsed += elapsed;
            if (update.elapsed < update.duration)
            {
                if (DEBUG && PERCENT && update.params.percent)
                {
                    var change = percentageList[update.params.percent];
                    change.amounts[change.current++] = 0;
                    if (change.current === rollingAverage)
                    {
                        change.current = 0;
                    }
                }
                continue;
            }
            else
            {
                update.elapsed = 0;
            }
        }
        var start, result;
        if (DEBUG && panels.percent)
        {
            start = performance.now();
            result = update.callback(elapsed, update.params);
            current = performance.now() - start;
            if (update.params.percent)
            {
                var change = percentageList[update.params.percent];
                change.amounts[change.current++] = current;
                if (change.current === rollingAverage)
                {
                    change.current = 0;
                }
            }
            else<commit_msg>Missed one option<commit_after>/*
    update.js <https://github.com/davidfig/update>
    License: MIT license <https://github.com/davidfig/update/license>
    Author: <NAME>
    Copyright (c) 2016 YOPEY YOPEY LLC
*/

var list = [];
var FPS = 60;
var FPSActual;
var pause = false;
var pauseRegistrations = [];
var pauseElapsed = 0;

var startTime = 0;
var frameNumber = 0;
var lastUpdate = 0;
var lastFPS = '--';

var tolerance = 1;

var maxChange = 100;

var panels = {fps: null, meter: null, percent: null};
var percentageList = [];
var lastCount;

var DEBUG = false;
var COUNT = false;
var PERCENT = false;
var FPS = false;

// this is the number of entries to use in a rolling average to smooth the debug percentages
var rollingAverage = 500;

/**
 * must call Update.init before using Update
 * @param {boolean} debug - whether to turn on debug support (requires github.com/davidfig/debug)
 * @param {boolean=false|string} count - show debug counts (can supply side for panel, e.g., 'topleft')
 * @param {boolean=false|string} percent - show debug percentage
 * @param {boolean=false|string} FPS - show debug FPS
 */
function init(options)
{
    options = options || {};
    checkVisibility();
    FPSActual = 1000 / FPS;
    if (options.debug)
    {
        DEBUG = true;
        COUNT = options.count;
        PERCENT = options.percent;
        FPS = options.FPS;
        debugInit();
    }
}

// register functions to call after Update pauses or resumes
function registerPause(pause, resume)
{
    pauseRegistrations.push({ pause: pause, resume: resume});
}

function pauseGame()
{
    if (pause !== true)
    {
        pause = true;
        pauseElapsed = performance.now() - lastUpdate;
        updateOff = false;
        if (DEBUG)
        {
            debugPause();
        }
        for (var i = 0; i < pauseRegistrations.length; i++)
        {
            pauseRegistrations[i].pause();
        }
    }
}

function resumeGame()
{
    if (pause === true)
    {
        pause = false;
        lastUpdate = performance.now() - pauseElapsed;
        fpsReset();
        for (var i = 0; i < pauseRegistrations.length; i++)
        {
            pauseRegistrations[i].resume();
        }
        if (updateOff === true)
        {
            update();
        }
    }
}

function fpsReset()
{
    startTime = 0;
    frameNumber = 0;
    lastUpdate = 0;
    lastFPS = '--';
}

function updateOther(elapsed)
{
    var i = 0, _i = list.length;
    var total = 0, other = 0, updates = [], count = 0;
    while (i < _i)
    {
        var update = list[i++];
        if (update.pause)
        {
            continue;
        }
        if (update.duration !== 0)
        {
            update.elapsed += elapsed;
            if (update.elapsed < update.duration)
            {
                if (DEBUG && PERCENT && update.params.percent)
                {
                    var change = percentageList[update.params.percent];
                    change.amounts[change.current++] = 0;
                    if (change.current === rollingAverage)
                    {
                        change.current = 0;
                    }
                }
                continue;
            }
            else
            {
                update.elapsed = 0;
            }
        }
        var start, result;
        if (DEBUG && PERCENT && panels.percent)
        {
            start = performance.now();
            result = update.callback(elapsed, update.params);
            current = performance.now() - start;
            if (update.params.percent)
            {
                var change = percentageList[update.params.percent];
                change.amounts[change.current++] = current;
                if (change.current === rollingAverage)
                {
                    change.current = 0;
                }
            }
            else
{'fraction_non_alphanumeric': 0.11599844297391981, 'fraction_numerical': 0.009082652134423252, 'mean_word_length': 1.696047569080098, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '849453', 'n_tokens_mistral': 2304, 'n_tokens_neox': 2183, 'n_words': 604}