unescape vs standards compliant replacement (v3)

Revision 3 of this benchmark created on


Description

Remove unescape from codebase and replace with compliant replacement

Setup

let str = 'PasswordMaker©€𤭢';

Test runner

Ready to run.

Testing in
TestOps/sec
unescape
unescape(encodeURI(str));
ready
replacement
encodeURI(str).replace(/%[\da-f]{2}/gi, (char) => String.fromCodePoint(parseInt(char.replace(/%/, ""), 16)));
ready
looping bytearray
var uint8array = new TextEncoder().encode(str);
var byteStr = "";
for (var i = 0; i < uint8array.length; i++) {
  byteStr += String.fromCharCode(uint8array[i]);
}
ready
forEach bytearray
var uint8array = new TextEncoder().encode(str);
var byteStr = "";
uint8array.forEach((char) => byteStr += String.fromCharCode(char));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.