react-bytes

1.1.7 • Public • Published

react-bytes

Exchange int and short with bytes array

Installation

$ npm instal react-bytes

API

bytes2Short(arr, start)

transform bytes array to short

bytes2Short([1, 2], 0).should.equal(258);

bytes2Int(arr, start)

transform bytes array to int

bytes2Int([1, 2, 3, 4], 0).should.equal(16909060);

bytes2Long(arr, start)

transform bytes array to long

bytes2Long([1, 2, 3, 4, 5, 6, 7, 8], 0).should.equal(72623859790382856n);

bytes2Float(arr, start)

transform bytes array to float

bytes2Float([1, 2, 3, 4], 0).should.equal(2.387939260590663e-38);

short2Bytes(i)

transform short to bytes

int2Bytes(258).should.equal([1, 2]);

int2Bytes(i)

transform int to bytes

int2Bytes(16909060).should.equal([1, 2, 3, 4]);

long2Bytes(i)

transform long to bytes

long2Bytes(72623859790382856n).should.equal([1, 2, 3, 4, 5, 6, 7, 8]);

float2Bytes(i)

transform float to bytes

float2Bytes(2.387939260590663e-38).should.equal([1, 2, 3, 4]);

Readme

Keywords

Package Sidebar

Install

npm i react-bytes

Weekly Downloads

11

Version

1.1.7

License

MIT

Unpacked Size

6.49 kB

Total Files

5

Last publish

Collaborators

  • levy_hsu