extensions/html-language-features/server/src/modes/semanticTokens.ts/createMapping
function createMapping(origLegend: string[], newLegend: string[]): number[] | undefined {
	const mapping: number[] = [];
	let needsMapping = false;
	for (let origIndex = 0; origIndex < origLegend.length; origIndex++) {
		const entry = origLegend[origIndex];
		let newIndex = newLegend.indexOf(entry);
		if (newIndex === -1) {
			newIndex = newLegend.length;
			newLegend.push(entry);
		}
		mapping.push(newIndex);
		needsMapping = needsMapping || (newIndex !== origIndex);
	}
	return needsMapping ? mapping : undefined;
}