<commit_before>'use strict';

/**
 * Requirements
 * @ignore
 */
const Base = require('../Base.js').Base;


/**
 * Merges two object
 *
 * @param {*} target
 * @param {*} source
 */
function merge(target, source)
{
    if (Array.isArray(target))
    {
        if (Array.isArray(source))
        {
            target.push(...source);
        }
        else
        {
            target.push(source);
        }
    }
    else
    {
        for (const key in source)
        {
            if (typeof target[key] === 'function')
            {
                //nop
            }
            else if (typeof target[key] === 'undefined')
            {
                target[key] = source[key];
            }
            else
            {
                if (Array.isArray(target[key]))
                {
                    target[key].push(...source[key]);
                }
                else if (typeof source[key] === 'string' ||
                         typeof source[key] === 'number' ||
                         typeof source[key] === 'boolean')
                {
                    target[key] = source[key];
                }
                else
                {
                    merge(target[key], source[key]);
                }
            }
        }
    }
}


/**
 * Adds values to a configuration
 *
 * @param {*} data
 * @param {*} key
 * @param {*} type
 * @param {*} values
 */
function add(data, key, type, sourceType, values)
{
    // Get args
    if (typeof type !== 'function')
    {
        values = type;
        type = false;
        sourceType = false;
    }
    else if (typeof sourceType !== 'function')
    {
        values = sourceType;
        sourceType = type;
    }

    // Make sure key is there
    if (typeof data[key] === 'undefined')
    {
        data[key] = [];
    }

    // Get config
    let config = type
        ? data[key].find((i) =>
        {
            return (i && ((i.type === type) ||
                            (i.type instanceof Base && type instanceof Base && i.type.className === type.className)));
        })
        : data[key];
    if (!config)
    {
        config =
        {
            type: type,
            sourceType: sourceType
        };
        data[key].push(config);
    }

    // Merge
    merge(config, values);

    return true;
}<commit_msg>fix(application.Configuration): removes instanceof in favor of className check<commit_after>'use strict';

/**
 * Requirements
 * @ignore
 */
const Base = require('../Base.js').Base;


/**
 * Merges two object
 *
 * @param {*} target
 * @param {*} source
 */
function merge(target, source)
{
    if (Array.isArray(target))
    {
        if (Array.isArray(source))
        {
            target.push(...source);
        }
        else
        {
            target.push(source);
        }
    }
    else
    {
        for (const key in source)
        {
            if (typeof target[key] === 'function')
            {
                //nop
            }
            else if (typeof target[key] === 'undefined')
            {
                target[key] = source[key];
            }
            else
            {
                if (Array.isArray(target[key]))
                {
                    target[key].push(...source[key]);
                }
                else if (typeof source[key] === 'string' ||
                         typeof source[key] === 'number' ||
                         typeof source[key] === 'boolean')
                {
                    target[key] = source[key];
                }
                else
                {
                    merge(target[key], source[key]);
                }
            }
        }
    }
}


/**
 * Adds values to a configuration
 *
 * @param {*} data
 * @param {*} key
 * @param {*} type
 * @param {*} values
 */
function add(data, key, type, sourceType, values)
{
    // Get args
    if (typeof type !== 'function')
    {
        values = type;
        type = false;
        sourceType = false;
    }
    else if (typeof sourceType !== 'function')
    {
        values = sourceType;
        sourceType = type;
    }

    // Make sure key is there
    if (typeof data[key] === 'undefined')
    {
        data[key] = [];
    }

    // Get config
    let config = type
        ? data[key].find((i) =>
        {
            return (i && ((i.type === type) ||
                            (i.type.className && type.className && i.type.className === type.className)));
        })
        : data[key];
    if (!config)
    {
        config =
        {
            type: type,
            sourceType: sourceType
        };
        data[key].push(config);
    }

    // Merge
    merge(config, values);

    return true;
}
{'fraction_non_alphanumeric': 0.1429483088704531, 'fraction_numerical': 0.0, 'mean_word_length': 1.1900326036329762, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7570977', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1287, 'n_words': 291}