• Encodes a String. The characters &<>"'/ are encoded. If str is undefined or null an empty string will be returned.

    Parameters

    • str: string | number

      String that should be encoded

    Returns string

    encoded String

    import escape from "../string-escape";

    let escapedHtml = escape("hello <b>World</b>");
    escapedHtml === "hello &lt;b&gt;World&lt;&#x2F;b&gt;";