Skip to content

add encoder/decoder map generate #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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