Skip to content

🎥 Make videos programmatically with React

347 B
Raw Blame
export const applyTextTransform = (text: string, transform: string): string => {
	if (transform === 'uppercase') {
		return text.toUpperCase();
	}

	if (transform === 'lowercase') {
		return text.toLowerCase();
	}

	if (transform === 'capitalize') {
		return text.replace(/\b(?<!['\u2019])\w/g, (char) => char.toUpperCase());
	}

	return text;
};