Add all BENNC message types with unit tests
This commit is contained in:
21
src/utilities/number.ts
Normal file
21
src/utilities/number.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user