Skip to content

Commit

Permalink
nitty nit
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbandes committed Jun 24, 2024
1 parent 4fcfe39 commit 2da6cf1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions typescript/examples/validate/scripts/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function validate(
throw new Error(`Missing schema ${record.schemaId} for channel ${record.id}`);
}
let messageDeserializer: (data: ArrayBufferView) => unknown;
if (record.messageEncoding === "ros1" && schema.encoding === "ros1msg") {
if (schema.encoding === "ros1msg" && record.messageEncoding === "ros1") {
const reader = new ROS1LazyMessageReader(
parseMessageDefinition(new TextDecoder().decode(schema.data)),
);
Expand All @@ -150,14 +150,14 @@ async function validate(
}
return reader.readMessage(data).toJSON();
};
} else if (record.messageEncoding === "cdr" && schema.encoding === "ros2msg") {
} else if (schema.encoding === "ros2msg" && record.messageEncoding === "cdr") {
const reader = new ROS2MessageReader(
parseMessageDefinition(new TextDecoder().decode(schema.data), {
ros2: true,
}),
);
messageDeserializer = (data) => reader.readMessage(data);
} else if (record.messageEncoding === "protobuf" && schema.encoding === "protobuf") {
} else if (schema.encoding === "protobuf" && record.messageEncoding === "protobuf") {
const root = protobufjs.Root.fromDescriptor(FileDescriptorSet.decode(schema.data));
const type = root.lookupType(schema.name);

Expand Down

0 comments on commit 2da6cf1

Please sign in to comment.