Skip to content

Commit

Permalink
Add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Feb 5, 2024
1 parent 235b82c commit 2f8394b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/protobuf-bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ server would usually do.

| code generator | bundle size | minified | compressed |
|---------------------|------------------------:|-----------------------:|-------------------:|
| protobuf-es | 96,959 b | 41,479 b | 10,750 b |
| protobuf-es | 97,101 b | 41,461 b | 10,746 b |
| protobuf-javascript | 394,384 b | 288,654 b | 45,122 b |
5 changes: 4 additions & 1 deletion packages/protobuf/src/private/util-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function makeUtilCommon(): Omit<Util, "newFieldList" | "initFields"> {
t = target as AnyMessage,
s = source as PartialMessage<AnyMessage>;
if (s[localName] === undefined) {
// TODO if source is a Message instance, we should use isFieldSet() here to support future field presence
continue;
}
switch (member.kind) {
Expand Down Expand Up @@ -105,7 +106,7 @@ export function makeUtilCommon(): Omit<Util, "newFieldList" | "initFields"> {
t[localName] = (s[localName] as any[]).map((val) =>
val instanceof mt ? val : new mt(val),
);
} else if (s[localName] !== undefined) {
} else {
const val = s[localName];
if (mt.fieldWrapper) {
if (
Expand All @@ -124,6 +125,7 @@ export function makeUtilCommon(): Omit<Util, "newFieldList" | "initFields"> {
}
}
},
// TODO use isFieldSet() here to support future field presence
equals<T extends Message<T>>(
type: MessageType<T>,
a: T | PlainMessage<T> | undefined | null,
Expand Down Expand Up @@ -202,6 +204,7 @@ export function makeUtilCommon(): Omit<Util, "newFieldList" | "initFields"> {
}
});
},
// TODO use isFieldSet() here to support future field presence
clone<T extends Message<T>>(message: T): T {
const type = message.getType(),
target = new type(),
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf/src/proto2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const proto2 = makeProtoRuntime(
normalizeFieldInfos(source, false),
);
},
// TODO merge with proto3 and initExtensionField
// TODO merge with proto3 and initExtensionField, also see initPartial, equals, clone
(target: Message): void => {
for (const member of target.getType().fields.byMember()) {
const name = member.localName,
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf/src/proto3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const proto3 = makeProtoRuntime(
normalizeFieldInfos(source, true),
);
},
// TODO merge with proto2 and initExtensionField
// TODO merge with proto2 and initExtensionField, also see initPartial, equals, clone
(target: Message): void => {
for (const member of target.getType().fields.byMember()) {
if (member.opt) {
Expand Down

0 comments on commit 2f8394b

Please sign in to comment.