function trim(buffer) {
  const index = buffer.findIndex((v) => v === 0);
  if (index < 0) return buffer;
  return buffer.subarray(0, index);
}
/**
 * Remove the trailing null codes
 * @param buffer
 */
Remove the trailing null codes
@param buffer
Remove the trailing null codes @param buffer
function trim(buffer) {
  const index = buffer.findIndex((v) => v === 0);
  if (index < 0) return buffer;
  return buffer.subarray(0, index);
}
function trim ( buffer ) { const index = buffer . findIndex ( ( v ) => v === 0 ) ; if ( index < 0 ) return buffer ; return buffer . subarray ( 0 , index ) ; }
Remove the trailing null codes
 @param buffer
Remove the trailing null codes @param buffer