import { SchemaProps } from '../types' ; import { writeUInt32 } from '../varint' ; export const generateKey = ( schemaProp ) : Buffer => { let wireType ; const dataType = schemaProp . dataType ?? schemaProp . type ; switch ( dataType ) { case 'bytes' : case 'string' : case 'object' : case 'array' : wireType = 2 ; break ; default : wireType = 0 ; break ; } const keyAsVarInt = writeUInt32 ( ( schemaProp . fieldNumber << 3 ) | wireType ) ; return keyAsVarInt ; } ;