export function formatString(
	str: string,
	format: 'pascal' | 'camel' | 'snake' | 'titleCase',
): string {
	if (format === 'titleCase') {
		return str
			.split('_')
			.map(word => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase())
			.join(' ')
	}

	if (format === 'pascal') {
		return str
			.split('_')
			.map(word => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase())
			.join('')
	}
	if (format === 'camel') {
		return str
			.split('_')
			.map((word, index) => (index === 0 ? word : word[0].toUpperCase() + word.slice(1)))
			.join('')
	}
	if (format === 'snake') {
		return [...str]
			.map((letter) => {
				if (letter === letter.toUpperCase()) {
					return `_${letter.toLowerCase()}`
				}
				return letter
			})
			.join('')
	}
	return str
}
