let a = [8, 129, 128, 4, 21, 0, 0, 0, 0, 29, 0, 0, 0, 0, 34, 16, 10, 14, 8, 198, 195, 144, 11, 18, 1, 48, 26, 0, 50, 0, 64, 100]
// let a = [8, 129, 128, 4, 21, 0, 0, 0, 0, 29, 0, 0, 0, 0, 34, 16, 10, 14, 8, 198, 195, 144, 11, 18, 1, 48, 26, 0, 50, 0, 64, 100]
function Uint8ArrayToString(fileData){
var dataString = "";
for (var i = 0; i < fileData.length; i++) {
dataString += String.fromCharCode(fileData[i]);
}
return dataString
}
// console.log(Uint8ArrayToString(a))
function to16(num){
return num.toString(16).padStart(2,'0')
}
function to16All(arr){
let res = []
arr.forEach((v,i)=>{
if(i%2==0){
res.push(to16(a[i])+to16(a[i+1]))
}
})
return res
}
console.log(to16All(a))
function to10All(arr){
let res = []
arr.forEach((v,i)=>{
let l = parseInt(v.slice(0,2),16)
let r = parseInt(v.slice(-2),16)
res.push(l,r)
})
return res
}
// let b = [ "0881","8004",'1500','0000','001d','0000','0000','222c',
// '0a2a','08b0','9301','1201','301a','0022','0431','3133',
// '3432','0038','0040','0052','005a','117b','2264','6576',
// '6963','6522','3a22','3131','3334','227d' ]
let b = [ "0887","8004",'1500','0000','001d','0000','0000','2209',
'2207','08d0','9301','1201','30']
// let b = [ "0881","8004",'1500','0000','001d','0000','0000','2210',
// '0a0e','08fc','fcdb','0b12','0130','1a00','3200','4064' ]
console.log(to10All(b))
console.log([...Array(3)].map(v=>Math.floor(Math.random()*256)))
console