Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function quotePropertyName(original: string): string {
const escaped = utf16StringEscape(original)
const quoted = `"${escaped}"`
if (original.length === 0) {
return quoted
} else if (!isES3IdentifierStart(original.codePointAt(0) as number)) {
return quoted
} else if (escaped !== original) {
return quoted
} else if (legalizeName(original) !== original) {
return quoted
} else {
return original
}
}