{"ScriptPreparationCode":"function get1024Bytes(n) {\r\n const bytes = new Uint8Array(n * 1024);\r\n for (let i = 0; i \u003C bytes.length; i \u002B= 1) {\r\n bytes[i] = Math.random() * 0xff;\r\n }\r\n return bytes;\r\n}\r\n\r\nconst bytes = get1024Bytes(1024);\r\n\r\n/*\r\n Note that Function.prototype.apply() has a limit, so not using it to creat binary string here for convenience.\r\n \r\n To use it, split the array into smaller chunks first.\r\n \r\n String.fromCodePoint.apply(null, bytes); // bytes.length should not exceed the maximum\r\n\r\n See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply\r\n*/\r\n\r\nconst binString = Array.from(bytes, (byte) =\u003E String.fromCodePoint(byte)).join(\u0022\u0022);","TestCases":[{"Name":"Uint8Array.from \u002B codePointAt","Code":"return Uint8Array.from(binString, (m) =\u003E m.codePointAt(0));","IsDeferred":false},{"Name":"Uint8Array.from \u002B charCodeAt","Code":"return Uint8Array.from(binString, (m) =\u003E m.charCodeAt(0));","IsDeferred":false},{"Name":"for-loop \u002B codePointAt","Code":"const bytes = new Uint8Array(binString.length);\r\nfor (let i = 0; i \u003C bytes.length; i \u002B= 1) {\r\n bytes[i] = binString[i].codePointAt(0);\r\n}\r\nreturn bytes;","IsDeferred":false},{"Name":"for-loop \u002B charCodeAt","Code":"const bytes = new Uint8Array(binString.length);\r\nfor (let i = 0; i \u003C bytes.length; i \u002B= 1) {\r\n bytes[i] = binString[i].charCodeAt(0);\r\n}\r\nreturn bytes;","IsDeferred":false},{"Name":"for-loop \u002B Uint8Array.from \u002B codePointAt (small chunk)","Code":" const QUANTUM = 128;\r\n const bytes = new Uint8Array(binString.length);\r\n for (let i = 0; i \u003C binString.length; i \u002B= QUANTUM) {\r\n let j = i;\r\n for (const b of Uint8Array.from(binString.slice(i, i \u002B QUANTUM), (m) =\u003E m.codePointAt(0))) {\r\n bytes[j] = b;\r\n j \u002B= 1;\r\n }\r\n }\r\n return bytes;","IsDeferred":false},{"Name":"for-loop \u002B Uint8Array.from \u002B charCodeAt (small chunk)","Code":" const QUANTUM = 128;\r\n const bytes = new Uint8Array(binString.length);\r\n for (let i = 0; i \u003C binString.length; i \u002B= QUANTUM) {\r\n let j = i;\r\n for (const b of Uint8Array.from(binString.slice(i, i \u002B QUANTUM), (m) =\u003E m.charCodeAt(0))) {\r\n bytes[j] = b;\r\n j \u002B= 1;\r\n }\r\n }\r\n return bytes;","IsDeferred":false},{"Name":"for-loop \u002B Uint8Array.from \u002B codePointAt (big chunk)","Code":" const QUANTUM = 32768;\r\n const bytes = new Uint8Array(binString.length);\r\n for (let i = 0; i \u003C binString.length; i \u002B= QUANTUM) {\r\n let j = i;\r\n for (const b of Uint8Array.from(binString.slice(i, i \u002B QUANTUM), (m) =\u003E m.codePointAt(0))) {\r\n bytes[j] = b;\r\n j \u002B= 1;\r\n }\r\n }\r\n return bytes;","IsDeferred":false},{"Name":"for-loop \u002B Uint8Array.from \u002B charCodeAt (big chunk)","Code":" const QUANTUM = 32768;\r\n const bytes = new Uint8Array(binString.length);\r\n for (let i = 0; i \u003C binString.length; i \u002B= QUANTUM) {\r\n let j = i;\r\n for (const b of Uint8Array.from(binString.slice(i, i \u002B QUANTUM), (m) =\u003E m.charCodeAt(0))) {\r\n bytes[j] = b;\r\n j \u002B= 1;\r\n }\r\n }\r\n return bytes;","IsDeferred":false}]}