Exchange int and short with bytes array
$ npm instal react-bytes
transform bytes array to short
bytes2Short([1, 2], 0).should.equal(258);
transform bytes array to int
bytes2Int([1, 2, 3, 4], 0).should.equal(16909060);
transform bytes array to long
bytes2Long([1, 2, 3, 4, 5, 6, 7, 8], 0).should.equal(72623859790382856n);
transform bytes array to float
bytes2Float([1, 2, 3, 4], 0).should.equal(2.387939260590663e-38);
transform short to bytes
int2Bytes(258).should.equal([1, 2]);
transform int to bytes
int2Bytes(16909060).should.equal([1, 2, 3, 4]);
transform long to bytes
long2Bytes(72623859790382856n).should.equal([1, 2, 3, 4, 5, 6, 7, 8]);
transform float to bytes
float2Bytes(2.387939260590663e-38).should.equal([1, 2, 3, 4]);