How to use the quicktype-core/dist/language/JavaScript.legalizeName function in quicktype-core

To help you get started, we’ve selected a few quicktype-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github segmentio / typewriter / src / commands / gen-js / typescript.ts View on Github external
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
  }
}