function

escapeHTML

function escapeHTML(
input: string | number | boolean | object
): string;

Escape the following characters in a string:

  • " becomes """
  • & becomes "&"
  • ' becomes "'"
  • < becomes "&lt;"
  • > becomes "&gt;"

This function is optimized for large input. On an M1X, it processes 480 MB/s - 20 GB/s, depending on how much data is being escaped and whether there is non-ASCII text.

Non-string types are converted to a string before escaping.