Unload number to a binary string array of bits, array of bools, object of bits, object of bools.
npm install bitunloaderv1.2.1Unload a number to a binary string array of bits, array of bools, object of bits, object of bools.
Very usefull when working with modbus devices which use word data types. Often, modbus device manufactures use a single 16 bit word to represent up to 16 different boolean values according to the individual bits in the word. Accessing those individual bits is made easier by transforming the word into individual bits in a way what matches your coding style.

npm install bitunloadermode which must be string, array or object.type is required which must be bit or bool.padding property sets the length of the result output to at least* this length.signed property invokes 'signed integer mode', which automatically pads the result to 16 bits. The least significant bit becomes the sign bit, which allows a value range between -32,767 (sign bit = 1) and +32,767 (sign bit = 0). Inputting values larger than this range will result in an error.true or false.false.9987.814bitunloader(5, {mode: 'string'}); //result will be '101'
Or simply:
bitunloader(100); //result will be '1100100'
Array mode:
bitunloader(3, {mode: 'array', type: 'bit'})
//result will be [1,1]
Object mode:
bitunloader(2, {mode: 'object', type: 'bool'})
//result will be {b0: false, b1: true}
Signed mode: (can be used with any other mode)
bitunloader(-5, {signed: true});
//result will be '1000000000000101'
bitunloader(1277, {mode: 'string', padding: 16})
//result will be ''0000010011111101'
Pad to 8 bits on a 17 bit number:
bitunloader(69420, {padding: 8})
//result will be '10000111100101100' (still 17 bits long)