Skip to content

Conversation

findstr
Copy link

@findstr findstr commented Jun 12, 2024

For some reasons, we need to dynamically decode some structures, like the following:

const schema = pbjs.parseSchema(`
  message Demo {
    optional int32 x = 1;
    optional float y = 2;
  }
`).compile();

const buffer = schema.encode("Demo",{x: 1, y: 2});
console.log(buffer);

const message = schema.decode("Demo", buffer);
console.log(message);

So I added two maps, mapping the names of the structures to the encoder and decoder functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant