<commit_before>/*global require:false*/
/*global define:false*/

/**
 * @module span
 * @private
 */

import FontMetrics from './fontMetrics.js';

const NUMBER_FORMATTER = new Intl.NumberFormat('en-US', {
    useGrouping: false,
    maximumSignificantDigits: 5
});

/**
 * Return a string made up of the concatenated arguments.
 * Each arguments can be either a string, which is unchanged,
 * or a number, which is converted to a string with at most 5 fractional digits.
 *
 * @param {...string} args
 * @return {string}
 * @memberof module:span
 * @private
 */
function toString() {
    let result = '';
    for (const arg of arguments) {
        if (typeof arg === 'number') {
            result += NUMBER_FORMATTER.format(arg);
        } else if (typeof arg === 'string') {
            result += arg;
        } else if (Array.isArray(arg)) {
            for (const elem of arg) {
                result += toString(elem);
            }
        } else if (arg) {
            result += arg.toString();
        }
    }
    return result;
}


//----------------------------------------------------------------------------
// SPAN
//----------------------------------------------------------------------------

/**
 * A span is the most elementary element that can be rendered.
 * It is composed of an optional body of text and an optional list
 * of children (other spans). Each span can be decorated with
 * CSS classes and style attributes.
 *
 * @param {string|Span|Span[]} content the items 'contained' by this node
 * @param {string} classes list of classes attributes associated with this node
 * @return {void}
 * @class
 * @global
 * @memberof module:span
 * @property {string} type - For example, `'command'`, `'mrel'`, etc...
 * @property {string} classes - A string of space separated CSS classes
 * associated with this element
 * @property {Span[]} children - An array, potentially empty, of spans which<commit_msg>Fix IE11 comptaibility issue<commit_after>/*global require:false*/
/*global define:false*/

/**
 * @module span
 * @private
 */

import FontMetrics from './fontMetrics.js';

const NUMBER_FORMATTER = new Intl.NumberFormat('en-US', {
    useGrouping: false,
    maximumSignificantDigits: 5
});

/**
 * Return a string made up of the concatenated arguments.
 * Each arguments can be either a string, which is unchanged,
 * or a number, which is converted to a string with at most 5 fractional digits.
 *
 * @param {...string} args
 * @return {string}
 * @memberof module:span
 * @private
 */
function toString() {
    let result = '';
    // Note: IE11 (even transpiled for with Babel) does not deal well with 
    // for(... of arguments) (because arguments is an iteratable, not an array)
    // The forEach construct below works.
    Array.from(arguments).forEach(function(arg) {
        if (typeof arg === 'number') {
            result += NUMBER_FORMATTER.format(arg);
        } else if (typeof arg === 'string') {
            result += arg;
        } else if (Array.isArray(arg)) {
            for (const elem of arg) {
                result += toString(elem);
            }
        } else if (arg) {
            result += arg.toString();
        }
    });
    return result;
}


//----------------------------------------------------------------------------
// SPAN
//----------------------------------------------------------------------------

/**
 * A span is the most elementary element that can be rendered.
 * It is composed of an optional body of text and an optional list
 * of children (other spans). Each span can be decorated with
 * CSS classes and style attributes.
 *
 * @param {string|Span|Span[]} content the items 'contained' by this node
 * @param {string} classes list of classes attributes associated with this node
 * @return {void}
 * @class
 * @global
 * @memberof module:span
 * @property {string} type - For example, `'command'`, `'mrel'`, etc...
 * @property {string} classes - A string of space separated CSS classes
 * associated with this element
 * @property {Span[]} children - An array, potentially empty, of spans which
{'fraction_non_alphanumeric': 0.18633692458374143, 'fraction_numerical': 0.0019588638589618022, 'mean_word_length': 2.147149460708783, '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': '182947', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1050, 'n_words': 422}