import { writeUInt32 , readUInt32 } from './varint' ; export const writeBytes = ( bytes ) : Buffer => Buffer . concat ( [ writeUInt32 ( bytes . length ) , bytes ] ) ; export const readBytes = ( buffer , offset ) : [ Buffer , number ] => { const [ byteLength , keySize ] = readUInt32 ( buffer , offset ) ; return [ buffer . subarray ( offset + keySize , offset + keySize + byteLength ) , byteLength + keySize ] ; } ;