<commit_before>/**
 * Contains methods for UUID generation
 * @module uuid
 */

/**
 * @class UUID
 */
var C = Y.namespace('Crypto'),
    u;

/**
 * Generate a UUID, optionally formatted according to RFC 4122
 *
 * @method generateUUID
 * @static
 * @param formatted Boolean If true, UUID will be formatted according to RFC 4122
 * @retuns string UUID either formatted with dashes or raw.
 */
C.UUID = u = function(formatted) {
    var uuid = u._randomUUID();
    return formatted ? u._formatUUIDString(uuid) : uuid;
};

Y.mix(u, {
/**
 * Format a 32-character string in the accepted format for UUIDs
 *
 * @method _formatUUIDString
 * @static
 * @private
 * @param uuid string 32-character string to have dashes added to match RFC 4122
 */
_formatUUIDString: function(uuid) {
    var work = [];
    work.push(uuid.substring(0, 8));
    work.push(uuid.substring(8, 12));
    work.push(uuid.substring(12, 16));
    work.push(uuid.substring(16, 20));
    work.push(uuid.substring(20));

    return work.join('-');
},

/**
 * Generate 32-bits of entropy and return them as an unsigned integer
 *
 * This version uses Math.random, so the entropy is only as good as the browser
 * vendor's default random method. Further, since you can't generate an arbitary
 * amount of entropy at once, this function is likely going to be called multiple
 * times. It is impossible to guarantee quality of entropy using this method, but
 * it is the fastest and simplest way to generate entropy. This is a 'good-enough'
 * fallback for many uses, but if you need real guarantees of randomness, then
 * you should consider other options.
 *
 * @method _gen32BitEntropy
 * @static
 * @private
 * @returns int
 */
_gen32BitEntropy: function() {
    /*jslint bitwise: true */
    return (Math.random() * 0x100000000) | 0;
},

/**
 * Convert a 32-bit integer into an 8-character hex string
 *
 * @method _intToHex
 * @static
 * @private
 * @params number int A number assumed to have been normalized to be a 32-bit unsigned integer.
 * @returns string
 */
_intToHex: function(number) { return ('00000000' + number.toString(16)).slice(-8); },

/**
 * Generate a random UUID, 128-bits of hex-enocded data, with the appopriate flags set for the random variant on UUID
 *
 * @method _randomUUID
 * @static
 * @private
 * @returns string
 */
_randomUUID: function() {<commit_msg>Fix Lint Doc Errors<commit_after>/**
 * Contains methods for UUID generation
 * @module uuid
 */

/**
 * @class UUID
 */
var C = Y.namespace('Crypto'),
    u;

/**
 * Generate a UUID, optionally formatted according to RFC 4122
 *
 * @method generateUUID
 * @static
 * @param formatted Boolean If true, UUID will be formatted according to RFC 4122
 * @return string UUID either formatted with dashes or raw.
 */
C.UUID = u = function(formatted) {
    var uuid = u._randomUUID();
    return formatted ? u._formatUUIDString(uuid) : uuid;
};

Y.mix(u, {
/**
 * Format a 32-character string in the accepted format for UUIDs
 *
 * @method _formatUUIDString
 * @static
 * @private
 * @param uuid string 32-character string to have dashes added to match RFC 4122
 * @return string formatted UUID
 */
_formatUUIDString: function(uuid) {
    var work = [];
    work.push(uuid.substring(0, 8));
    work.push(uuid.substring(8, 12));
    work.push(uuid.substring(12, 16));
    work.push(uuid.substring(16, 20));
    work.push(uuid.substring(20));

    return work.join('-');
},

/**
 * Generate 32-bits of entropy and return them as an unsigned integer
 *
 * This version uses Math.random, so the entropy is only as good as the browser
 * vendor's default random method. Further, since you can't generate an arbitary
 * amount of entropy at once, this function is likely going to be called multiple
 * times. It is impossible to guarantee quality of entropy using this method, but
 * it is the fastest and simplest way to generate entropy. This is a 'good-enough'
 * fallback for many uses, but if you need real guarantees of randomness, then
 * you should consider other options.
 *
 * @method _gen32BitEntropy
 * @static
 * @private
 * @return int
 */
_gen32BitEntropy: function() {
    /*jslint bitwise: true */
    return (Math.random() * 0x100000000) | 0;
},

/**
 * Convert a 32-bit integer into an 8-character hex string
 *
 * @method _intToHex
 * @static
 * @private
 * @param number int A number assumed to have been normalized to be a 32-bit unsigned integer.
 * @return string
 */
_intToHex: function(number) { return ('00000000' + number.toString(16)).slice(-8); },

/**
 * Generate a random UUID, 128-bits of hex-enocded data, with the appopriate flags set for the random variant on UUID
 *
 * @method _randomUUID
 * @static
 * @private
 * @return string
 */
_randomUUID: function() {
{'fraction_non_alphanumeric': 0.11108764519535375, 'fraction_numerical': 0.028299894403379093, 'mean_word_length': 3.625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '7278185', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1414, 'n_words': 555}