diff --git a/src/util.js b/src/util.js --- a/src/util.js +++ b/src/util.js @@ -16,6 +16,9 @@ export function bytes2int32s(arr){ return res; } +/** + * Converts a 32 bit integer into 4 bytes in little endian order. + */ export function int322bytes(x){ let res=[]; for(let i=0;i<4;i++){ @@ -25,6 +28,15 @@ export function int322bytes(x){ return res; } +/** + * Converts a 32 bit integer into 4 bytes in big endian order. + */ +export function int322bytesBE(x){ + let res=int322bytes(x); + res.reverse(); + return res; +} + export function int32s2bytes(arr){ return arr.map(int322bytes).reduce((acc,bytes)=>acc.concat(bytes)); }