Skip to content

Question about old versus new functionality #984

Open
@ghost

Description

protobuf.js version: 4.1.2 and 6.8.0

Apologies, but this issue is more of a general question than an actual issue. I'm quite new and trying to understand some differences between an older version of this module and the newest version.

In the version around 4.1.2, I might use a proto file like this:

var protobufjs = require("protobufjs");
var builder = protobufjs.loadProtoFile( "myProtoFile.proto" );
var myThing = builder.build( "myThing" );

I'm struggling to see how to recreate this in the new version. I have run something like this:

let builder = protobufjs.loadSync("myProtoFile.proto");
let myThing = builder["myThing"];

In the new version, I can see my defined message types as elements of the myThing object, but it's not the same as the myThing object created using version 4. Specifically, If I have a message type called NameChange, then this is what the older version looked like:

>myThing.NameChange
{ [Function: Message]
  encode: [Function],
  decode: [Function],
  decodeDelimited: [Function],
  decode64: [Function],
  decodeHex: [Function],
  decodeJSON: [Function] }

such that it is a constructor itself. The new version is an object containing functions.

Obviously I'm kind of at a loss, so if I'm hopelessly misguided, I apologize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions