Skip to content
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

Is the encoding method here different than other protobufs? #105

Open
kkailiwang opened this issue Jul 5, 2019 · 0 comments
Open

Is the encoding method here different than other protobufs? #105

kkailiwang opened this issue Jul 5, 2019 · 0 comments
Labels

Comments

@kkailiwang
Copy link

kkailiwang commented Jul 5, 2019

My project takes in encoded proto strings (which were created from google's protobuf) and I just need a package that can decode them into javascript. Is this package's decoding process only for messages encoded by mapbox/pbf?

I ask because it works when I encode and then decode a message, like:
let pbf = new pbf(); pbf.writeString('hi'); pbf.finish(); return pbf.readString();

but not when I just decode a message (this is embedded):

let pbf = new Pbf();
pbf.writeRawMessage(dataString); 
pbf.finish();
//or just new Pbf(dataString)

const readFields = pbf.readFields(function(tag) { 
    const tagNeeded = tagArray[0];  
    if (tag === tagNeeded) {
        if (tagArray.length == 1) {
          return pbf.readFloat();
        }
        tagArray.splice(0, 1); 
        pbf.readMessage(readFields, {});
         
    }, {});
}
   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants