<commit_before>/**
 * nengine-cli
 * https://nuintun.github.io/nengine-cli
 *
 * Licensed under the MIT license
 * https://github.com/Nuintun/nengine-cli/blob/master/LICENSE
 */

'use strict';

// Import internal libs
var fs = require('fs'),
    path = require('path');

/**
 * Normalize path
 * @param path
 * @returns {string}
 */
function normalize(path){
    var sepRE = /\\/g;

    // Replace \ to /
    return path.replace(sepRE, '/');
}

/**
 * Search module in path
 * @param moudule
 * @param root
 * @returns {*}
 */
function search(moudule, root){
    var pkg, main = null;

    // Read package.json
    try {
        pkg = require(path.join(root, 'package.json'));

        // Find moudule package.json
        if (pkg.name === moudule) {
            main = path.join(root, pkg.main || 'index');

            // Is module main exists
            if (fs.existsSync(main) || fs.existsSync(main + '.js')) {
                return normalize(main);
            }
        }
    } catch (e) {
        // Failed to parse package.json
        return main;
    }

    // Return module path
    return main;
}

/**
 * Recurse directory
 * @param moudule
 * @param root
 * @param subdir
 * @returns {*}
 */
function recurse(moudule, root, subdir){<commit_msg>Update resolve.js<commit_after>/**
 * nengine-cli
 * https://nuintun.github.io/nengine-cli
 *
 * Licensed under the MIT license
 * https://github.com/Nuintun/nengine-cli/blob/master/LICENSE
 */

'use strict';

// Import internal libs
var fs = require('fs'),
    path = require('path');

/**
 * Normalize path
 * @param path
 * @returns {string}
 */
function normalize(path){
    var sepRE = /\\/g;

    // Replace \ to /
    return path.replace(sepRE, '/');
}

/**
 * Search module in path
 * @param moudule
 * @param root
 * @returns {*}
 */
function search(moudule, root){
    var pkg, main = null;

    // Read package.json
    try {
        pkg = require(path.join(root, 'package.json'));

        // Find moudule package.json
        if (pkg.name === moudule) {
            main = path.join(root, pkg.main || 'index');

            // Is module exists, test main + '.js' first, because most modules without extension name
            if (fs.existsSync(main + '.js') || fs.existsSync(main)) {
                return normalize(main);
            }
        }
    } catch (e) {
        // Failed to parse package.json
        return main;
    }

    // Return module path
    return main;
}

/**
 * Recurse directory
 * @param moudule
 * @param root
 * @param subdir
 * @returns {*}
 */
function recurse(moudule, root, subdir){
{'fraction_non_alphanumeric': 0.15500579822187863, 'fraction_numerical': 0.0, 'mean_word_length': 2.1715686274509802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1918580', 'n_tokens_mistral': 834, 'n_tokens_neox': 813, 'n_words': 213}