Function esSafeId

  • Converts arbitrary string to string safe to be used as ECMAScript identifier.

    1. Converts empty string to _.
    2. Converts [reserved word] to the form __${id}__.
    3. Encodes subsequent Unicode code points unsafe to be used in [identifiers] as a series of _x${hex}x${hex}..._ symbols.
    4. Does not modify ECMAScript-safe identifiers.

    Parameters

    • id: string

      Arbitrary string to convert.

    Returns string

    ECMAScript-safe identifier.

Generated using TypeDoc