param buf1 param buf2 returns const lte = ( buf1 , buf2 ) : boolean => { return Buffer . compare ( buf1 , buf2 ) <= 0 ; } ; param buf1 param buf2 returns const lt = ( buf1 , buf2 ) : boolean => { return Buffer . compare ( buf1 , buf2 ) < 0 ; } ; param buf1 param buf2 returns const gt = ( buf1 , buf2 ) : boolean => { return Buffer . compare ( buf1 , buf2 ) > 0 ; } ; param buf1 param buf2 returns const gte = ( buf1 , buf2 ) : boolean => { return Buffer . compare ( buf1 , buf2 ) >= 0 ; } ; param buf1 param buf2 returns const max = ( buf1 , buf2 ) : Buffer => { return gte ( buf1 , buf2 ) ? buf1 : buf2 ; } ; param buf1 param buf2 returns const min = ( buf1 , buf2 ) : Buffer => { return lte ( buf1 , buf2 ) ? buf1 : buf2 ; } ; param buf param totalWidth returns const padLeft = ( buf , totalWidth ) : Buffer => { if ( buf . length > totalWidth ) { throw new Error ( 'Attempting to pad a buffer which is too large' ) ; } const newBuf = Buffer . alloc ( totalWidth ) ; newBuf . fill ( buf , totalWidth - buf . length , totalWidth ) ; return newBuf ; } ; param buf param totalWidth returns const padRight = ( buf , totalWidth ) : Buffer => { if ( buf . length > totalWidth ) { throw new Error ( 'Attempting to pad a buffer which is too large' ) ; } const newBuf = Buffer . alloc ( totalWidth ) ; newBuf . fill ( buf , 0 , buf . length ) ; return newBuf ; } ; /**
 * A collection of useful utilities for comparing buffers.
 */ export const bufferUtils = { lt , lte , gt , gte , max , min , padLeft , padRight , } ;