<commit_before>var async  = require('async'),
    fs     = require('fs'),
    glob   = require('glob'),
    path   = require('path'),
    semver = require('semver');

// -- Utilites -----------------------------------------------------------------

function extend(obj) {
    Array.prototype.slice.call(arguments, 1).forEach(function (source) {
        if (!source) { return; }

        for (var key in source) {
            obj[key] = source[key];
        }
    });

    return obj;
}

function getHandlebarsSemver(handlebars) {
    var version = handlebars.VERSION || '';

    // Makes sure the Handlebars version is a valid semver.
    if (version && !semver.valid(version)) {
        version = version.replace(/(\d\.\d)\.(\D.*)/, '$1.0-$2');
    }

    return version;
}

// -- Constructor --------------------------------------------------------------

function ExpressHandlebars(config) {
    config || (config = {});

    var handlebars = config.handlebars || require('handlebars');

    if ('extname'     in config) { this.extname     = config.extname;     }
    if ('layoutsDir'  in config) { this.layoutsDir  = config.layoutsDir;  }
    if ('partialsDir' in config) { this.partialsDir = config.partialsDir; }

    this.defaultLayout     = config.defaultLayout;
    this.handlebars        = handlebars;
    this.handlebarsVersion = getHandlebarsSemver(handlebars);
    this.helpers           = extend({}, handlebars.helpers, config.helpers);

    this.compiled    = {};
    this.precompiled = {};

    this.engine = this.renderView.bind(this);
}

ExpressHandlebars._dirCache     = {};
ExpressHandlebars._fileCache    = {};
ExpressHandlebars._pendingReads = {};

extend(ExpressHandlebars.prototype, {<commit_msg>Rearrange property initialization in ExpressHandlebars constructor<commit_after>var async  = require('async'),
    fs     = require('fs'),
    glob   = require('glob'),
    path   = require('path'),
    semver = require('semver');

// -- Utilites -----------------------------------------------------------------

function extend(obj) {
    Array.prototype.slice.call(arguments, 1).forEach(function (source) {
        if (!source) { return; }

        for (var key in source) {
            obj[key] = source[key];
        }
    });

    return obj;
}

function getHandlebarsSemver(handlebars) {
    var version = handlebars.VERSION || '';

    // Makes sure the Handlebars version is a valid semver.
    if (version && !semver.valid(version)) {
        version = version.replace(/(\d\.\d)\.(\D.*)/, '$1.0-$2');
    }

    return version;
}

// -- Constructor --------------------------------------------------------------

function ExpressHandlebars(config) {
    config || (config = {});

    var handlebars = config.handlebars || require('handlebars');

    if ('extname'     in config) { this.extname     = config.extname;     }
    if ('layoutsDir'  in config) { this.layoutsDir  = config.layoutsDir;  }
    if ('partialsDir' in config) { this.partialsDir = config.partialsDir; }

    this.defaultLayout = config.defaultLayout;
    this.handlebars    = handlebars;
    this.helpers       = extend({}, handlebars.helpers, config.helpers);

    this.handlebarsVersion = getHandlebarsSemver(handlebars);

    this.compiled    = {};
    this.precompiled = {};

    this.engine = this.renderView.bind(this);
}

ExpressHandlebars._dirCache     = {};
ExpressHandlebars._fileCache    = {};
ExpressHandlebars._pendingReads = {};

extend(ExpressHandlebars.prototype, {
{'fraction_non_alphanumeric': 0.20964962665134979, 'fraction_numerical': 0.0022975301550832855, 'mean_word_length': 2.1924839596700276, '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': '2236163', 'n_tokens_mistral': 994, 'n_tokens_neox': 970, 'n_words': 197}