HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
 
const DATA = {
    '#': '&#x23;',
    $: '&#x24;',
    '%': '&#x25;',
    '&': '&amp;',
    "'": '&#x27;',
    '(': '&#x28;',
    ')': '&#x29;',
    '+': '&#x2b;',
    ';': '&#x3b;',
    '^': '&#x5e;',
    À: '&Agrave;',
    Á: '&Aacute;',
    Â: '&Acirc;',
    Ã: '&Atilde;',
    Ä: '&Auml;',
    Å: '&Aring;',
    Æ: '&AElig;',
    Ç: '&Ccedil;',
    È: '&Egrave;',
    '~': '&#x7e;',
    '¡': '&iexcl;',
    '¢': '&cent;',
    '£': '&pound;',
    '¤': '&curren;',
    '¥': '&yen;',
    '¦': '&brvbar;',
    '§': '&sect;',
    '¨': '&uml;',
    '©': '&copy;',
    ª: '&ordf;',
    '«': '&laquo;',
    '¬': '&not;',
    '': '&shy;',
    '®': '&reg;',
    '¯': '&macr;',
    '°': '&deg;',
    '±': '&plusmn;',
    '²': '&sup2;',
    '³': '&sup3;',
    '´': '&acute;',
    µ: '&micro;',
    '¶': '&para;',
    '·': '&middot;',
    '¸': '&cedil;',
    '¹': '&sup1;',
    º: '&ordm;',
    '»': '&raquo;',
    '¼': '&frac14;',
    '½': '&frac12;',
    '¾': '&frac34;',
    '¿': '&iquest;',
    É: '&Eacute;',
    Ê: '&Ecirc;',
    Ë: '&Euml;',
    Ì: '&Igrave;',
    Í: '&Iacute;',
    Î: '&Icirc;',
    Ï: '&Iuml;',
    Ð: '&ETH;',
    Ñ: '&Ntilde;',
    Ò: '&Ograve;',
    Ó: '&Oacute;',
    Ô: '&Ocirc;',
    Õ: '&Otilde;',
    Ö: '&Ouml;',
    '×': '&times;',
    Ø: '&Oslash;',
    Ù: '&Ugrave;',
    Ú: '&Uacute;',
    Û: '&Ucirc;',
    Ü: '&Uuml;',
    Ý: '&Yacute;',
    Þ: '&THORN;',
    ß: '&szlig;',
    à: '&agrave;',
    á: '&aacute;',
    â: '&acirc;',
    ã: '&atilde;',
    ä: '&auml;',
    å: '&aring;',
    æ: '&aelig;',
    ç: '&ccedil;',
    è: '&egrave;',
    é: '&eacute;',
    ê: '&ecirc;',
    ë: '&euml;',
    ì: '&igrave;',
    í: '&iacute;',
    î: '&icirc;',
    ï: '&iuml;',
    ð: '&eth;',
    ñ: '&ntilde;',
    ò: '&ograve;',
    ó: '&oacute;',
    ô: '&ocirc;',
    õ: '&otilde;',
    ö: '&ouml;',
    '÷': '&divide;',
    ø: '&oslash;',
    ù: '&ugrave;',
    ú: '&uacute;',
    û: '&ucirc;',
    ü: '&uuml;',
    ý: '&yacute;',
    þ: '&thorn;',
    ÿ: '&yuml;',
    Ā: '&#x100;',
    ā: '&#x101;',
    Ă: '&#x102;',
    ă: '&#x103;',
    Ą: '&#x104;',
    '’': '&#8217;',
    '‐': '&#8208;',
    : 'a&#768;',
    '<': '&#x3C;',
    '>': '&#x3E;',
}
const charMap = new Map(Object.entries(DATA));
Tests:
  • MAP

     
    const esapiEncoder = (text) => {
        if (!text) return '';
        let newText = '';
        for (let i = 0, e = text.length; i < e; i++) {
            const char = text[i];
            newText += charMap.get(char) ?? char;
        }
        return newText;
    };
    esapiEncoder('OIFJOSIJFOIJFIOSJFOSIDJFOISJDFOISJFIO>')
  • OBJ

     
    const esapiEncoder = (text) => {
        if (!text) return '';
        let newText = '';
        for (let i = 0, e = text.length; i < e; i++) {
            const char = text[i];
            newText += DATA[char] ?? char;
        }
        return newText;
    };
    esapiEncoder('OIFJOSIJFOIJFIOSJFOSIDJFOISJDFOISJFIO>')
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    MAP
    OBJ

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Chrome 132 on Windows
View result in a separate tab
Test name Executions per second
MAP 429008.0 Ops/sec
OBJ 180067.7 Ops/sec