mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
15 lines
394 B
TypeScript
15 lines
394 B
TypeScript
import { lookupProtobufType, ProtoSource } from './lookupProtobufType';
|
|
|
|
export function encodeProtobuf(
|
|
source: ProtoSource,
|
|
type: string,
|
|
data: Record<string, any>,
|
|
) {
|
|
const message = lookupProtobufType(source, type);
|
|
const verification = message.verify(data);
|
|
|
|
if (verification !== null) throw new Error(verification);
|
|
|
|
return message.encode(message.create(data)).finish();
|
|
}
|