Permalink
Browse files

Other: Use more precise types for message-like plain objects

  • Loading branch information...
dcodeIO committed Mar 21, 2017
1 parent 5a1f861 commit 588ffd9b129869de0abcef1d69bfa18f2f25d8e1
@@ -101,7 +101,7 @@ Note that **Message** refers to any message type below.
```
* **Message.encode**(message: `Message|Object` [, writer: `Writer`]): `Writer`<br />
is an automatically generated message specific encoder expecting a valid message or plain object. Note that this methods does not implicitly verify the message and that it's up to the user to make sure that the data can actually be encoded properly.
is an automatically generated message specific encoder expecting a valid message or plain object. Note that this method does not implicitly verify the message and that it's up to the user to make sure that the data can actually be encoded properly.
```js
var buffer = AwesomeMessage.encode(message).finish();
@@ -394,7 +394,7 @@ function buildType(ref, type) {
push("");
pushComment([
"Encodes the specified " + type.name + " message. Does not implicitly {@link " + fullName + ".verify|verify} messages.",
"@param {" + fullName + "|Object} " + (config.beautify ? "message" : "m") + " " + type.name + " message or plain object to encode",
"@param {" + fullName + "|Object.<string,*>} " + (config.beautify ? "message" : "m") + " " + type.name + " message or plain object to encode",
"@param {$protobuf.Writer} [" + (config.beautify ? "writer" : "w") + "] Writer to encode to",
"@returns {$protobuf.Writer} Writer"
]);
@@ -404,7 +404,7 @@ function buildType(ref, type) {
push("");
pushComment([
"Encodes the specified " + type.name + " message, length delimited. Does not implicitly {@link " + fullName + ".verify|verify} messages.",
"@param {" + fullName + "|Object} message " + type.name + " message or plain object to encode",
"@param {" + fullName + "|Object.<string,*>} message " + type.name + " message or plain object to encode",
"@param {$protobuf.Writer} [writer] Writer to encode to",
"@returns {$protobuf.Writer} Writer"
]);
@@ -456,11 +456,10 @@ function buildType(ref, type) {
push("");
pushComment([
"Verifies " + aOrAn(type.name) + " message.",
"@param {" + fullName + "|Object} " + (config.beautify ? "message" : "m") + " " + type.name + " message or plain object to verify",
"@param {Object.<string,*>} " + (config.beautify ? "message" : "m") + " " + type.name + " object to verify",
"@returns {?string} `null` if valid, otherwise the reason why it is not"
]);
buildFunction(type, "verify", protobuf.verifier(type));
}
if (config.convert) {
@@ -570,7 +569,7 @@ function buildService(ref, service) {
push("");
pushComment([
method.comment || "Calls " + method.name + ".",
"@param {" + method.resolvedRequestType.fullName.substring(1) + "|Object} request " + method.resolvedRequestType.name + " message or plain object",
"@param {" + method.resolvedRequestType.fullName.substring(1) + "|Object.<string,*>} request " + method.resolvedRequestType.name + " message or plain object",
"@param {" + cbName + "} callback Node-style callback called with the error, if any, and " + method.resolvedResponseType.name,
"@returns {undefined}"
]);
@@ -585,7 +584,7 @@ function buildService(ref, service) {
method.comment || "Calls " + method.name + ".",
"@name " + name(service.name) + "#" + lcName,
"@function",
"@param {" + method.resolvedRequestType.fullName.substring(1) + "|Object} request " + method.resolvedRequestType.name + " message or plain object",
"@param {" + method.resolvedRequestType.fullName.substring(1) + "|Object.<string,*>} request " + method.resolvedRequestType.name + " message or plain object",
"@returns {Promise<"+method.resolvedResponseType.fullName.substring(1)+">} Promise",
"@variation 2"
]);
@@ -136,7 +136,7 @@ Class.prototype = Message;
* Encodes a message of this type.
* @name Class#encode
* @function
* @param {Message|Object} message Message to encode
* @param {Message|Object.<string,*>} message Message to encode
* @param {Writer} [writer] Writer to use
* @returns {Writer} Writer
*/
@@ -145,7 +145,7 @@ Class.prototype = Message;
* Encodes a message of this type preceeded by its length as a varint.
* @name Class#encodeDelimited
* @function
* @param {Message|Object} message Message to encode
* @param {Message|Object.<string,*>} message Message to encode
* @param {Writer} [writer] Writer to use
* @returns {Writer} Writer
*/
@@ -170,6 +170,6 @@ Class.prototype = Message;
* Verifies a message of this type.
* @name Class#verify
* @function
* @param {Message|Object} message Message or plain object to verify
* @param {Message|Object.<string,*>} message Message or plain object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
@@ -34,7 +34,7 @@ function Message(properties) {
/**
* Encodes a message of this type.
* @param {Message|Object} message Message to encode
* @param {Message|Object.<string,*>} message Message to encode
* @param {Writer} [writer] Writer to use
* @returns {Writer} Writer
*/
@@ -44,7 +44,7 @@ Message.encode = function encode(message, writer) {
/**
* Encodes a message of this type preceeded by its length as a varint.
* @param {Message|Object} message Message to encode
* @param {Message|Object.<string,*>} message Message to encode
* @param {Writer} [writer] Writer to use
* @returns {Writer} Writer
*/
@@ -78,7 +78,7 @@ Message.decodeDelimited = function decodeDelimited(reader) {
* Verifies a message of this type.
* @name Message.verify
* @function
* @param {Message|Object} message Message or plain object to verify
* @param {Message|Object.<string,*>} message Message or plain object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Message.verify = function verify(message) {
@@ -13,7 +13,7 @@ var Field = require("./field");
* @extends ReflectionObject
* @constructor
* @param {string} name Oneof name
* @param {string[]|Object} [fieldNames] Field names
* @param {string[]|Object.<string,*>} [fieldNames] Field names
* @param {Object.<string,*>} [options] Declared options
*/
function OneOf(name, fieldNames, options) {
@@ -21,7 +21,7 @@ var util = require("../util/minimal");
* A service method part of a {@link rpc.ServiceMethodMixin|ServiceMethodMixin} and thus {@link rpc.Service} as created by {@link Service.create}.
* @typedef rpc.ServiceMethod
* @type {function}
* @param {Message|Object} request Request message or plain object
* @param {Message|Object.<string,*>} request Request message or plain object
* @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message
* @returns {Promise<Message>} Promise if `callback` has been omitted, otherwise `undefined`
*/
@@ -79,7 +79,7 @@ function Service(rpcImpl, requestDelimited, responseDelimited) {
* @param {Method|rpc.ServiceMethod} method Reflected or static method
* @param {function} requestCtor Request constructor
* @param {function} responseCtor Response constructor
* @param {Message|Object} request Request message or plain object
* @param {Message|Object.<string,*>} request Request message or plain object
* @param {rpc.ServiceMethodCallback} callback Service callback
* @returns {undefined}
*/
@@ -398,7 +398,7 @@ Type.prototype.setup = function setup() {
/**
* Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.
* @param {Message|Object} message Message instance or plain object
* @param {Message|Object.<string,*>} message Message instance or plain object
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} writer
*/
@@ -408,7 +408,7 @@ Type.prototype.encode = function encode_setup(message, writer) {
/**
* Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.
* @param {Message|Object} message Message instance or plain object
* @param {Message|Object.<string,*>} message Message instance or plain object
* @param {Writer} [writer] Writer to encode to
* @returns {Writer} writer
*/
@@ -443,7 +443,7 @@ Type.prototype.decodeDelimited = function decodeDelimited(reader) {
/**
* Verifies that field values are valid and that required fields are present.
* @param {Message|Object} message Message to verify
* @param {Object.<string,*>} message Plain object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Type.prototype.verify = function verify_setup(message) {
@@ -452,7 +452,7 @@ Type.prototype.verify = function verify_setup(message) {
/**
* Creates a new message of this type from a plain object. Also converts values to their respective internal types.
* @param {Object.<string,*>} object Plain object
* @param {Object.<string,*>} object Plain object to convert
* @returns {Message} Message instance
*/
Type.prototype.fromObject = function fromObject(object) {
@@ -59,7 +59,7 @@ $root.Test1 = (function() {
/**
* Encodes the specified Test1 message. Does not implicitly {@link Test1.verify|verify} messages.
* @param {Test1|Object} message Test1 message or plain object to encode
* @param {Test1|Object.<string,*>} message Test1 message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -77,7 +77,7 @@ $root.Test1 = (function() {
/**
* Encodes the specified Test1 message, length delimited. Does not implicitly {@link Test1.verify|verify} messages.
* @param {Test1|Object} message Test1 message or plain object to encode
* @param {Test1|Object.<string,*>} message Test1 message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -132,7 +132,7 @@ $root.Test1 = (function() {
/**
* Verifies a Test1 message.
* @param {Test1|Object} message Test1 message or plain object to verify
* @param {Object.<string,*>} message Test1 object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Test1.verify = function verify(message) {
@@ -246,7 +246,7 @@ $root.Test2 = (function() {
/**
* Encodes the specified Test2 message. Does not implicitly {@link Test2.verify|verify} messages.
* @param {Test2|Object} message Test2 message or plain object to encode
* @param {Test2|Object.<string,*>} message Test2 message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -258,7 +258,7 @@ $root.Test2 = (function() {
/**
* Encodes the specified Test2 message, length delimited. Does not implicitly {@link Test2.verify|verify} messages.
* @param {Test2|Object} message Test2 message or plain object to encode
* @param {Test2|Object.<string,*>} message Test2 message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -304,7 +304,7 @@ $root.Test2 = (function() {
/**
* Verifies a Test2 message.
* @param {Test2|Object} message Test2 message or plain object to verify
* @param {Object.<string,*>} message Test2 object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Test2.verify = function verify(message) {
@@ -97,7 +97,7 @@ $root.Message = (function() {
/**
* Encodes the specified Message message. Does not implicitly {@link Message.verify|verify} messages.
* @param {Message|Object} message Message message or plain object to encode
* @param {Message|Object.<string,*>} message Message message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -138,7 +138,7 @@ $root.Message = (function() {
/**
* Encodes the specified Message message, length delimited. Does not implicitly {@link Message.verify|verify} messages.
* @param {Message|Object} message Message message or plain object to encode
* @param {Message|Object.<string,*>} message Message message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -234,7 +234,7 @@ $root.Message = (function() {
/**
* Verifies a Message message.
* @param {Message|Object} message Message message or plain object to verify
* @param {Object.<string,*>} message Message object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Message.verify = function verify(message) {
@@ -57,7 +57,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Tile message. Does not implicitly {@link vector_tile.Tile.verify|verify} messages.
* @param {vector_tile.Tile|Object} message Tile message or plain object to encode
* @param {vector_tile.Tile|Object.<string,*>} message Tile message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -72,7 +72,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Tile message, length delimited. Does not implicitly {@link vector_tile.Tile.verify|verify} messages.
* @param {vector_tile.Tile|Object} message Tile message or plain object to encode
* @param {vector_tile.Tile|Object.<string,*>} message Tile message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -123,7 +123,7 @@ $root.vector_tile = (function() {
/**
* Verifies a Tile message.
* @param {vector_tile.Tile|Object} message Tile message or plain object to verify
* @param {Object.<string,*>} message Tile object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Tile.verify = function verify(message) {
@@ -295,7 +295,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Value message. Does not implicitly {@link vector_tile.Tile.Value.verify|verify} messages.
* @param {vector_tile.Tile.Value|Object} message Value message or plain object to encode
* @param {vector_tile.Tile.Value|Object.<string,*>} message Value message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -321,7 +321,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Value message, length delimited. Does not implicitly {@link vector_tile.Tile.Value.verify|verify} messages.
* @param {vector_tile.Tile.Value|Object} message Value message or plain object to encode
* @param {vector_tile.Tile.Value|Object.<string,*>} message Value message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -388,7 +388,7 @@ $root.vector_tile = (function() {
/**
* Verifies a Value message.
* @param {vector_tile.Tile.Value|Object} message Value message or plain object to verify
* @param {Object.<string,*>} message Value object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Value.verify = function verify(message) {
@@ -605,7 +605,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Feature message. Does not implicitly {@link vector_tile.Tile.Feature.verify|verify} messages.
* @param {vector_tile.Tile.Feature|Object} message Feature message or plain object to encode
* @param {vector_tile.Tile.Feature|Object.<string,*>} message Feature message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -633,7 +633,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Feature message, length delimited. Does not implicitly {@link vector_tile.Tile.Feature.verify|verify} messages.
* @param {vector_tile.Tile.Feature|Object} message Feature message or plain object to encode
* @param {vector_tile.Tile.Feature|Object.<string,*>} message Feature message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -705,7 +705,7 @@ $root.vector_tile = (function() {
/**
* Verifies a Feature message.
* @param {vector_tile.Tile.Feature|Object} message Feature message or plain object to verify
* @param {Object.<string,*>} message Feature object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Feature.verify = function verify(message) {
@@ -932,7 +932,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Layer message. Does not implicitly {@link vector_tile.Tile.Layer.verify|verify} messages.
* @param {vector_tile.Tile.Layer|Object} message Layer message or plain object to encode
* @param {vector_tile.Tile.Layer|Object.<string,*>} message Layer message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -957,7 +957,7 @@ $root.vector_tile = (function() {
/**
* Encodes the specified Layer message, length delimited. Does not implicitly {@link vector_tile.Tile.Layer.verify|verify} messages.
* @param {vector_tile.Tile.Layer|Object} message Layer message or plain object to encode
* @param {vector_tile.Tile.Layer|Object.<string,*>} message Layer message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
@@ -1031,7 +1031,7 @@ $root.vector_tile = (function() {
/**
* Verifies a Layer message.
* @param {vector_tile.Tile.Layer|Object} message Layer message or plain object to verify
* @param {Object.<string,*>} message Layer object to verify
* @returns {?string} `null` if valid, otherwise the reason why it is not
*/
Layer.verify = function verify(message) {
Oops, something went wrong.

0 comments on commit 588ffd9

Please sign in to comment.