Add all BENNC message types with unit tests

This commit is contained in:
Jack Hadrill
2022-02-06 20:34:13 +00:00
parent 7d1a0991e4
commit e758de7ef4
28 changed files with 708 additions and 12539 deletions

21
src/utilities/number.ts Normal file
View File

@@ -0,0 +1,21 @@
/**
* Pack a number to a 2 byte Uint16 buffer (big endian).
* @param number The number to pack.
* @returns The packed buffer.
*/
export function numberToUint16BE (number: number): Buffer {
const ret = Buffer.alloc(2)
ret.writeUInt16BE(number)
return ret
}
/**
* Pack a number to a 4 byte Uint32 buffer (big endian).
* @param number The number to pack.
* @returns The packed buffer.
*/
export function numberToUint32BE (number: number): Buffer {
const ret = Buffer.alloc(4)
ret.writeUInt32BE(number)
return ret
}