in packages/metro-transform-plugins/src/normalizePseudoGlobals.js [69:96]
function getShortName(fullName: string, usedNames: Set<string>): string {
// Try finding letters that are semantically relatable to the name
// of the variable given. For instance, in XMLHttpRequest, it will
// first match "X", then "H", then "R".
const regexp = /^[^A-Za-z]*([A-Za-z])|([A-Z])[a-z]|([A-Z])[A-Z]+$/g;
let match;
while ((match = regexp.exec(fullName))) {
const name = (match[1] || match[2] || match[3] || '').toLowerCase();
if (!name) {
throw new ReferenceError(
'Could not identify any valid name for ' + fullName,
);
}
if (!usedNames.has(name)) {
usedNames.add(name);
return name;
}
}
throw new ReferenceError(
`Unable to determine short name for ${fullName}. The variables are not unique: ${Array.from(
usedNames,
).join(', ')}`,
);
}