style: NapProto

This commit is contained in:
手瓜一十雪 2024-10-12 21:35:49 +08:00
parent 938a84a460
commit a2c4498694

View File

@ -99,17 +99,18 @@ class NapProtoMsg<T extends ProtoMessageType> {
this._field = Object.keys(fields).map(key => {
const field = fields[key];
if (field.kind === 'scalar') {
const repeatType = field.repeated
? [ScalarType.STRING, ScalarType.BYTES].includes(field.type)
? RepeatType.UNPACKED
: RepeatType.PACKED
: RepeatType.NO;
return {
no: field.no,
name: key,
kind: 'scalar',
T: field.type,
opt: field.optional,
repeat: field.repeated
? [ScalarType.STRING, ScalarType.BYTES].includes(field.type)
? RepeatType.UNPACKED
: RepeatType.PACKED
: RepeatType.NO,
repeat: repeatType,
};
} else if (field.kind === 'message') {
const rt = NapProtoMsgCache.get(field.type()) ?? (() => {