{"ScriptPreparationCode":"function bigIntToBigEndianBytesLoopParseInt(value) {\r\n const hex = value.toString(16).padStart(16, \u00270\u0027);\r\n const bytes = new Uint8Array(8);\r\n for (let i = 0; i \u003C 8; i\u002B\u002B) {\r\n bytes[i] = parseInt(hex.slice(i * 2, i * 2 \u002B 2), 16);\r\n }\r\n return bytes;\r\n}\r\n\r\nfunction bigIntToBigEndianBytesLoopConstructor(value) {\r\n const hex = value.toString(16).padStart(16, \u00270\u0027);\r\n const bytes = new Uint8Array(8);\r\n for (let i = 0; i \u003C 8; i\u002B\u002B) {\r\n bytes[i] = Number(hex.slice(i * 2, i * 2 \u002B 2), 16);\r\n }\r\n return bytes;\r\n}\r\n\r\nfunction bigIntToBigEndianBytesDataView(value) {\r\n const buf = new ArrayBuffer(8);\r\n const view = new DataView(buf);\r\n\r\n view.setBigUint64(0, value);\r\n return new Uint8Array(buf);\r\n}\r\n\r\nfunction bigIntToUint8ArrayDirectConstructor(value) {\r\n const result = new Uint8Array(8);\r\n result[7] = Number(value \u0026 0xffn);\r\n result[6] = Number((value \u003E\u003E 8n) \u0026 0xffn);\r\n result[5] = Number((value \u003E\u003E 16n) \u0026 0xffn);\r\n result[4] = Number((value \u003E\u003E 24n) \u0026 0xffn );\r\n result[3] = Number((value \u003E\u003E 32n) \u0026 0xffn);\r\n result[2] = Number((value \u003E\u003E 40n) \u0026 0xffn);\r\n result[1] = Number((value \u003E\u003E 48n) \u0026 0xffn);\r\n result[0] = Number((value \u003E\u003E 56n) \u0026 0xffn);\r\n return result;\r\n}\r\n\r\n// Added by trincot: first split BigInt into two numbers (32 bit), then work with those only\r\nfunction bigIntToUint8ArrayDirectConstructor2(value) {\r\n const result = new Uint8Array(8);\r\n const low = Number(value \u0026 0xffffffffn);\r\n const high = Number(value \u003E\u003E 32n); \r\n result[7] = low \u0026 0xff;\r\n result[6] = (low \u003E\u003E\u003E 8) \u0026 0xff;\r\n result[5] = (low \u003E\u003E\u003E 16) \u0026 0xff;\r\n result[4] = low \u003E\u003E\u003E 24;\r\n result[3] = high \u0026 0xff;\r\n result[2] = (high \u003E\u003E\u003E 8) \u0026 0xff;\r\n result[1] = (high \u003E\u003E\u003E 16) \u0026 0xff;\r\n result[0] = high \u003E\u003E\u003E 24;\r\n return result;\r\n}\r\n\r\nfunction bigIntToUint8ArrayDirectParseInt(value) {\r\n const result = new Uint8Array(8);\r\n result[7] = parseInt(value \u0026 0xffn);\r\n result[6] = parseInt((value \u003E\u003E 8n) \u0026 0xffn);\r\n result[5] = parseInt((value \u003E\u003E 16n) \u0026 0xffn);\r\n result[4] = parseInt((value \u003E\u003E 24n) \u0026 0xffn );\r\n result[3] = parseInt((value \u003E\u003E 32n) \u0026 0xffn);\r\n result[2] = parseInt((value \u003E\u003E 40n) \u0026 0xffn);\r\n result[1] = parseInt((value \u003E\u003E 48n) \u0026 0xffn);\r\n result[0] = parseInt((value \u003E\u003E 56n) \u0026 0xffn);\r\n return result;\r\n}","TestCases":[{"Name":"Loop ParseInt","Code":"bigIntToBigEndianBytesLoopParseInt(32149814014n)","IsDeferred":false},{"Name":"Loop Constructor","Code":"bigIntToBigEndianBytesLoopConstructor(32149814014n)","IsDeferred":false},{"Name":"DataView","Code":"bigIntToBigEndianBytesDataView(32149814014n)","IsDeferred":false},{"Name":"Direct Constructor","Code":"bigIntToUint8ArrayDirectConstructor(32149814014n)","IsDeferred":false},{"Name":"Direct ParseInt","Code":"bigIntToUint8ArrayDirectParseInt(32149814014n)","IsDeferred":false},{"Name":"Direct Constructor with split","Code":"bigIntToUint8ArrayDirectConstructor2(32149814014n)","IsDeferred":false}]}