unescape vs standards compliant replacement (v4)

Revision 4 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
reduce
new TextEncoder().encode(str).reduce((byteStr, 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.