<commit_before>// ---------------------------------------------------------------------------------------------------------------------
// SyncService
//
// @module sync.js
// ---------------------------------------------------------------------------------------------------------------------

var _ = require('lodash');
var now = require('rfi-physics').now;

// ---------------------------------------------------------------------------------------------------------------------

function SyncServiceFactory(socket)
{
    function SyncService()
    {
        this.windowSize = 10;
        this.pingInterval = 5000;
        this.pingTimes = [];
    } // end SyncService

    SyncService.prototype = {
        get latency()
        {
            return ((_.reduce(this.pingTimes, function(pingSums, ping)
            {
                return pingSums + ping;
            }, 0) / this.pingTimes.length) / 2).toFixed(2);
        }
    }; // end prototype

    SyncService.prototype._ping = function()
    {
        var self = this;
        var startTime = now();
        socket.request('ping').then(function()
        {
            var pingTime = now() - startTime;
            self.pingTimes.push(pingTime);

            // Stay inside our window size<commit_msg>fixed NaN.<commit_after>// ---------------------------------------------------------------------------------------------------------------------
// SyncService
//
// @module sync.js
// ---------------------------------------------------------------------------------------------------------------------

var _ = require('lodash');
var now = require('rfi-physics').now;

// ---------------------------------------------------------------------------------------------------------------------

function SyncServiceFactory(socket)
{
    function SyncService()
    {
        this.windowSize = 10;
        this.pingInterval = 5000;
        this.pingTimes = [];
    } // end SyncService

    SyncService.prototype = {
        get latency()
        {
            return ((_.reduce(this.pingTimes, function(pingSums, ping)
            {
                return pingSums + ping;
            }, 0) / this.pingTimes.length) || 0 / 2).toFixed(2);
        }
    }; // end prototype

    SyncService.prototype._ping = function()
    {
        var self = this;
        var startTime = now();
        socket.request('ping').then(function()
        {
            var pingTime = now() - startTime;
            self.pingTimes.push(pingTime);

            // Stay inside our window size
{'fraction_non_alphanumeric': 0.37460443037974683, 'fraction_numerical': 0.007515822784810127, 'mean_word_length': 0.8446389496717724, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2806157', 'n_tokens_mistral': 576, 'n_tokens_neox': 533, 'n_words': 109}