<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

/**
 * Represents a UUID as defined by rfc4122.
 */
export interface UUID {

	/**
	 * @returns the canonical representation in sets of hexadecimal numbers separated by dashes.
	 */
	asHex(): string;

	equals(other: UUID): boolean;
}

class ValueUUID implements UUID {

	constructor(public _value: string) {
		// empty
	}

	public asHex(): string {
		return this._value;
	}

	public equals(other: UUID): boolean {
		return this.asHex() === other.asHex();
	}
}

class V4UUID extends ValueUUID {

	private static _chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];

	private static _timeHighBits = ['8', '9', 'a', 'b'];

	private static _oneOf(array: string[]): string {
		return array[Math.floor(array.length * Math.random())];
	}

	private static _randomHex(): string {
		return V4UUID._oneOf(V4UUID._chars);
	}

	constructor() {
		super([
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			'4',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._oneOf(V4UUID._timeHighBits),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
		].join(''));
	}
}

/**
 * An empty UUID that contains only zeros.
 */
export const empty: UUID = new ValueUUID('00000000-0000-0000-0000-000000000000');

export function v4(): UUID {
	return new V4UUID();
}

const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

export function isUUID(value: string): boolean {
	return _UUIDPattern.test(value);
}

/**
 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
 * @param value A uuid string.
 */
export function parse(value: string): UUID {
	if (!isUUID(value)) {
		throw new Error('invalid uuid');
	}

	return new ValueUUID(value);
}<commit_msg>debt - remove unused code<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

/**
 * Represents a UUID as defined by rfc4122.
 */
export interface UUID {

	/**
	 * @returns the canonical representation in sets of hexadecimal numbers separated by dashes.
	 */
	asHex(): string;

	equals(other: UUID): boolean;
}

class ValueUUID implements UUID {

	constructor(public _value: string) {
		// empty
	}

	public asHex(): string {
		return this._value;
	}

	public equals(other: UUID): boolean {
		return this.asHex() === other.asHex();
	}
}

class V4UUID extends ValueUUID {

	private static _chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];

	private static _timeHighBits = ['8', '9', 'a', 'b'];

	private static _oneOf(array: string[]): string {
		return array[Math.floor(array.length * Math.random())];
	}

	private static _randomHex(): string {
		return V4UUID._oneOf(V4UUID._chars);
	}

	constructor() {
		super([
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			'4',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._oneOf(V4UUID._timeHighBits),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			'-',
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
			V4UUID._randomHex(),
		].join(''));
	}
}

export function v4(): UUID {
	return new V4UUID();
}

const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

export function isUUID(value: string): boolean {
	return _UUIDPattern.test(value);
}

/**
 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
 * @param value A uuid string.
 */
export function parse(value: string): UUID {
	if (!isUUID(value)) {
		throw new Error('invalid uuid');
	}

	return new ValueUUID(value);
}
{'fraction_non_alphanumeric': 0.23492840994724942, 'fraction_numerical': 0.03278070836473248, 'mean_word_length': 2.7466478475652787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177199', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1883, 'n_words': 408}