es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
17 lines (15 loc) • 625 B
text/typescript
/**
* Converts the characters "&", "<", ">", '"', and "'" in `str` to their corresponding HTML entities.
* For example, "<" becomes "<".
*
* @param {string} str The string to escape.
* @returns {string} Returns the escaped string.
*
* @example
* escape('This is a <div> element.'); // returns 'This is a <div> element.'
* escape('This is a "quote"'); // returns 'This is a "quote"'
* escape("This is a 'quote'"); // returns 'This is a 'quote''
* escape('This is a & symbol'); // returns 'This is a & symbol'
*/
declare function escape(string?: string): string;
export { escape };