<commit_before>const dwarfNames = require('./names');

/**
 * Return first and last characters of the given name.
 *
 * @example
 *
 *  'Garrett' => ['g', 't']
 *  'Caira' => ['c', 'a']
 *
 * @private
 * @param {string} name
 * @return {string[]}
 */

function getNameLetters(name) {
    const letters = name.toLowerCase().split('');
    return letters.slice(0, 1).concat(letters.slice(-1));
}

/**
 * Are all passed names valid? (string of length > 0);
 *
 * @private
 * @param {string[]} names - Names to validate.
 * @return {boolean}
 */

function validNames(...names) {
    return names.every(name => typeof name === 'string' && name.length);
}

/**
 * Dwarfinate a name of the given kind (first name or last name).
 *
 * @private
 * @param {string} name - Name to dwarfinate.
 * @param {string} kind - Kind of name to dwarfinate (first or last).
 * @return {string} - Dwarfinated name.
 */

function dwarfName(name, kind = 'first') {
    const [first, last] = getNameLetters(name);
    return dwarfNames[kind].start[first] + dwarfNames[kind].end[last];
}

/**
 * Dwarfinate someone's first and last names.
 *
 * @example
 *
 *  '<NAME>' => '<NAME>'
 *  '<NAME>' => '<NAME>'
 *
 * @public
 * @param {string} first - First name to dwarfinate.
 * @param {string} last - Last name to dwarfinate.
 * @return {string} - Joined dwarfinated name.
 */

module.exports = function dwarfinate(first, last) {
    if (validNames(first, last)) {
        return `${dwarfName(first, 'first')} ${dwarfName(last, 'last')}`;
    } else {
        throw `Invalid names "${first}" and "${last}" given!`;
    }
};<commit_msg>Fixed typo in name.<commit_after>const dwarfNames = require('./names');

/**
 * Return first and last characters of the given name.
 *
 * @example
 *
 *  'Garrett' => ['g', 't']
 *  'Caira' => ['c', 'a']
 *
 * @private
 * @param {string} name
 * @return {string[]}
 */

function getNameLetters(name) {
    const letters = name.toLowerCase().split('');
    return letters.slice(0, 1).concat(letters.slice(-1));
}

/**
 * Are all passed names valid? (string of length > 0);
 *
 * @private
 * @param {string[]} names - Names to validate.
 * @return {boolean}
 */

function validNames(...names) {
    return names.every(name => typeof name === 'string' && name.length);
}

/**
 * Dwarfinate a name of the given kind (first name or last name).
 *
 * @private
 * @param {string} name - Name to dwarfinate.
 * @param {string} kind - Kind of name to dwarfinate (first or last).
 * @return {string} - Dwarfinated name.
 */

function dwarfName(name, kind = 'first') {
    const [first, last] = getNameLetters(name);
    return dwarfNames[kind].start[first] + dwarfNames[kind].end[last];
}

/**
 * Dwarfinate someone's first and last names.
 *
 * @example
 *
 *  '<NAME>' => '<NAME>'
 *  '<NAME>' => '<NAME>'
 *
 * @public
 * @param {string} first - First name to dwarfinate.
 * @param {string} last - Last name to dwarfinate.
 * @return {string} - Joined dwarfinated name.
 */

module.exports = function dwarfinate(first, last) {
    if (validNames(first, last)) {
        return `${dwarfName(first, 'first')} ${dwarfName(last, 'last')}`;
    } else {
        throw `Invalid names "${first}" and "${last}" given!`;
    }
};
{'fraction_non_alphanumeric': 0.18416149068322982, 'fraction_numerical': 0.002484472049689441, 'mean_word_length': 3.3942701227830834, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '2585704', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1056, 'n_words': 313}