function encode(data, options = EntityLevel.XML) {
    const opts = typeof options === "number" ? { level: options } : options;
    // Mode `UTF8` just escapes XML entities
    if (opts.mode === EncodingMode.UTF8)
        return escapeUTF8(data);
    if (opts.mode === EncodingMode.Attribute)
        return escapeAttribute(data);
    if (opts.mode === EncodingMode.Text)
        return escapeText(data);
    if (opts.level === EntityLevel.HTML) {
        if (opts.mode === EncodingMode.ASCII) {
            return encodeNonAsciiHTML(data);
        }
        return encodeHTML(data);
    }
    // ASCII and Extensive are equivalent
    return encodeXML(data);
}
/**
 * Encodes a string with entities.
 *
 * @param data String to encode.
 * @param options Encoding options.
 */
Encodes a string with entities.
@param data String to encode.
@param options Encoding options.
Encodes a string with entities . @param data String to encode . @param options Encoding options .
function encode(data, options = EntityLevel.XML) {
    const opts = typeof options === "number" ? { level: options } : options;
    if (opts.mode === EncodingMode.UTF8)
        return escapeUTF8(data);
    if (opts.mode === EncodingMode.Attribute)
        return escapeAttribute(data);
    if (opts.mode === EncodingMode.Text)
        return escapeText(data);
    if (opts.level === EntityLevel.HTML) {
        if (opts.mode === EncodingMode.ASCII) {
            return encodeNonAsciiHTML(data);
        }
        return encodeHTML(data);
    }
    return encodeXML(data);
}
function encode ( data , options = EntityLevel . XML ) { const opts = typeof options === "number" ? { level : options } : options ; if ( opts . mode === EncodingMode . UTF8 ) return escapeUTF8 ( data ) ; if ( opts . mode === EncodingMode . Attribute ) return escapeAttribute ( data ) ; if ( opts . mode === EncodingMode . Text ) return escapeText ( data ) ; if ( opts . level === EntityLevel . HTML ) { if ( opts . mode === EncodingMode . ASCII ) { return encodeNonAsciiHTML ( data ) ; } return encodeHTML ( data ) ; } return encodeXML ( data ) ; }
Encodes a string with entities.
Encodes a string with entities .
// Mode `UTF8` just escapes XML entities // ASCII and Extensive are equivalent