index.d.ts 792 B

12345678910111213141516171819202122
  1. /**
  2. * Sanitize a string for use as an identifier name
  3. *
  4. * Replaces invalid character sequences with _ and may add a _ prefix if the
  5. * resulting name would conflict with a JavaScript reserved name.
  6. *
  7. * @param key The desired identifier name
  8. * @param unique Append a hash of the key to the result
  9. */
  10. export declare function identifier(key: string, unique?: boolean): string
  11. /**
  12. * Sanitize a string for use as a property name
  13. *
  14. * By default uses `obj.key` notation, falling back to `obj["key"]` if the key
  15. * contains invalid characters or is an ECMAScript 3rd Edition reserved word
  16. * (required by IE8).
  17. *
  18. * @param obj If empty, returns only the possibly quoted key
  19. * @param key The property name
  20. */
  21. export function property(obj: string | null | undefined, key: string): string