pbf
pbf copied to clipboard
Is the encoding method here different than other protobufs?
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, {});
}, {});
}