Permalink
Browse files

Docs: Added a hint on using .create to initial example [ci skip]

  • Loading branch information...
dcodeIO committed Mar 23, 2017
1 parent b9574ad commit 6f8f2c1fdf92e6f81363d77bc059820b2376fe32
Showing with 2 additions and 2 deletions.
  1. +2 −2 README.md
@@ -183,7 +183,7 @@ protobuf.load("awesome.proto", function(err, root) {
throw err;
// Obtain a message type
var AwesomeMessage = root.lookup("awesomepackage.AwesomeMessage");
var AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage");
// Exemplary payload
var payload = { awesomeField: "AwesomeString" };
@@ -194,7 +194,7 @@ protobuf.load("awesome.proto", function(err, root) {
throw Error(errMsg);
// Create a new message
var message = AwesomeMessage.fromObject(payload);
var message = AwesomeMessage.fromObject(payload); // or use .create if payload is already known to be valid
// Encode a message to an Uint8Array (browser) or Buffer (node)
var buffer = AwesomeMessage.encode(message).finish();

0 comments on commit 6f8f2c1

Please sign in to comment.