<commit_before>/* global $ */
/* global StackTrace */
/* global aikey */
/* global appInsights */
/* exported Diagnostics */

// diagnostics module

var Diagnostics = (function () {
    var appDiagnostics = null;
    var itemDiagnostics = {};
    var lastUpdate = "";

    // Combines appDiagnostics and itemDiagnostics and returns a single object
    function get() {
        ensureAppDiagnostics();
        ensureItemDiagnostics();

        // Ideally we'd combine with Object.assign or the spread operator(...) but not all our browsers (IE) support that.
        // jQuery's extend should work everywhere.
        return $.extend({}, appDiagnostics, itemDiagnostics);
    }

    function set(field, value) { itemDiagnostics[field] = value; }

    function clear() { if (itemDiagnostics) itemDiagnostics = {}; }
<commit_msg>handle itemDiagnostics better - always ensure before using, and default/clear to null so ensureItemDiagnostics actually runs<commit_after>/* global $ */
/* global StackTrace */
/* global aikey */
/* global appInsights */
/* exported Diagnostics */

// diagnostics module

var Diagnostics = (function () {
    var appDiagnostics = null;
    var itemDiagnostics = null;
    var lastUpdate = "";

    // Combines appDiagnostics and itemDiagnostics and returns a single object
    function get() {
        ensureAppDiagnostics();
        ensureItemDiagnostics();

        // Ideally we'd combine with Object.assign or the spread operator(...) but not all our browsers (IE) support that.
        // jQuery's extend should work everywhere.
        return $.extend({}, appDiagnostics, itemDiagnostics);
    }

    function set(field, value) {
        ensureItemDiagnostics();
        itemDiagnostics[field] = value;
    }

    function clear() { itemDiagnostics = null; }

{'fraction_non_alphanumeric': 0.10831937465103295, 'fraction_numerical': 0.0, 'mean_word_length': 3.0089485458612977, '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': '4961190', 'n_tokens_mistral': 443, 'n_tokens_neox': 446, 'n_words': 157}