<commit_before>// Load modules

var Hoek = require('hoek');


// Cache configuration

exports.apply = function (options) {

    Hoek.assert(options, 'Missing options');

    // engine: 'memory', { engine: 'memory' }, { engine: implementation }

    var settings = {};
    if (typeof options === 'string') {
        settings.engine = options;
    }
    else if (typeof options.engine === 'object') {
        settings.engine = 'extension';
        settings.extension = options.engine;
        settings.partition = options.partition;
        return settings;
    }
    else {
        settings = Hoek.clone(options);
    }

    settings.partition = settings.partition || 'catbox';

    if (settings.engine === 'extension' && typeof settings.extension === 'object') {
        return settings;
    }

    Hoek.assert(['redis', 'mongodb', 'memory'].indexOf(settings.engine) !== -1, 'Unknown cache engine type: ' + settings.engine);

    if (settings.engine === 'redis') {
        settings.host = settings.host || '127.0.0.1';
        settings.port = settings.port || 6379;
    }
    else if (settings.engine === 'mongodb') {
        settings.host = settings.host || '127.0.0.1';
        settings.port = settings.port || 27017;
        settings.poolSize = settings.poolSize || 5;
    }
    else if (settings.engine === 'memory') {
        settings.maxByteSize = settings.maxByteSize || 100 * 1024 * 1024;         // Defaults to 100MB
    }

    return settings;
};<commit_msg>`Defaults.apply`: Tighten the type-checking for `settings.extension`.<commit_after>// Load modules

var Hoek = require('hoek');


// Cache configuration

exports.apply = function (options) {

    Hoek.assert(options, 'Missing options');

    // engine: 'memory', { engine: 'memory' }, { engine: implementation }

    var settings = {};
    if (typeof options === 'string') {
        settings.engine = options;
    }
    else if (typeof options.engine === 'object' && options.engine) {
        settings.engine = 'extension';
        settings.extension = options.engine;
        settings.partition = options.partition;
        return settings;
    }
    else {
        settings = Hoek.clone(options);
    }

    settings.partition = settings.partition || 'catbox';

    if (settings.engine === 'extension' && typeof settings.extension === 'object' && settings.extension) {
        return settings;
    }

    Hoek.assert(['redis', 'mongodb', 'memory'].indexOf(settings.engine) !== -1, 'Unknown cache engine type: ' + settings.engine);

    if (settings.engine === 'redis') {
        settings.host = settings.host || '127.0.0.1';
        settings.port = settings.port || 6379;
    }
    else if (settings.engine === 'mongodb') {
        settings.host = settings.host || '127.0.0.1';
        settings.port = settings.port || 27017;
        settings.poolSize = settings.poolSize || 5;
    }
    else if (settings.engine === 'memory') {
        settings.maxByteSize = settings.maxByteSize || 100 * 1024 * 1024;         // Defaults to 100MB
    }

    return settings;
};
{'fraction_non_alphanumeric': 0.15336411609498682, 'fraction_numerical': 0.024406332453825858, 'mean_word_length': 2.6279904306220097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '5766436', 'n_tokens_mistral': 927, 'n_tokens_neox': 848, 'n_words': 207}