Bit converter
This module is inspired by C# BitConverter
class to convert byte array to byte
, short
and int
.
The conversion to signed number is based on double complement.
This module is used often for serialport
development which requires a lot of byte array manipulation
Example
'use strict'; const BitConverter = ; const a = BitConverter; console // -1 //Starting index for the array = 1const b = BitConverter; console // -1
API
toByte(array[, startIndex])
toShort(array[, startIndex])
toInt(array[, startIndex])
array
the source array to be converted
startIndex
is the start index of the array, default is 0