Skip to content

Commit 47608dd

Browse files
committed
Document all the callbacks, see #527
1 parent 1a8c720 commit 47608dd

File tree

16 files changed

+248
-71
lines changed

16 files changed

+248
-71
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ Consolidates imports and converts between file formats.
331331
332332
-t, --target Specifies the target format. Also accepts a path to require a custom target.
333333
334-
json-module JSON representation as a module (AMD, CommonJS, global)
335334
json JSON representation
335+
json-module JSON representation as a module (AMD, CommonJS, global)
336336
proto2 Protocol Buffers, Version 2
337337
proto3 Protocol Buffers, Version 3
338-
static-module Static code without reflection as a module (AMD, CommonJS, global)
339338
static Static code without reflection
339+
static-module Static code without reflection as a module (AMD, CommonJS, global)
340340
341341
-p, --path Adds a directory to the include path.
342342
@@ -403,7 +403,7 @@ protobuf.js integrates into any browserify build-process. There are a few possib
403403

404404
* If performance is a concern or IE8 support is required, you should make sure to exclude the browserified `buffer` module and let protobuf.js do its thing with Uint8Array/Array instead.
405405
* If you do not need int64 support, you can exclude the `long` module.
406-
* If your application does not rely on the following modules and/or package size is a concern, you can also exclude `process` , `_process` and `fs`.
406+
* If your application does not rely on the following modules and package size is a concern, you can also exclude `process` , `_process` and `fs`.
407407
* If you have any special requirements, there is [the bundler](https://github.com/dcodeIO/protobuf.js/blob/master/scripts/bundle.js) as a reference.
408408

409409
Performance

dist/protobuf.js

Lines changed: 77 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

0 Bytes
Binary file not shown.

dist/protobuf.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codegen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var blockOpenRe = /[{[]$/,
1414
* @namespace
1515
* @function
1616
* @param {...string} params Function parameter names
17-
* @returns {CodegenInstance} Codegen instance
17+
* @returns {Codegen} Codegen instance
1818
* @property {boolean} supported Whether code generation is supported by the environment.
1919
* @property {boolean} verbose=false When set to true, codegen will log generated code to console. Useful for debugging.
2020
*/
@@ -26,11 +26,11 @@ function codegen() {
2626

2727
/**
2828
* A codegen instance as returned by {@link codegen}, that also is a {@link util.sprintf|sprintf}-like appender function.
29-
* @typedef CodegenInstance
29+
* @typedef Codegen
3030
* @type {function}
3131
* @param {string} format Format string
3232
* @param {...*} args Replacements
33-
* @returns {CodegenInstance} Itself
33+
* @returns {Codegen} Itself
3434
* @property {function(string=):string} str Stringifies the so far generated function source.
3535
* @property {function(string=, Object=):function} eof Ends generation and builds the function whilst applying a scope.
3636
*/

src/codegen/decode.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ var Enum = require("../enum"),
1414
codegen = require("../codegen");
1515

1616
/**
17-
* Decodes a message of `this` message's type.
17+
* A message decoder as generated by {@link codegen.decode.generate}.
18+
* @typedef Decoder
19+
* @type {function}
20+
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
21+
* @param {number} [length] Length of the message, if known beforehand
22+
* @returns {Message} Populated runtime message
23+
* @this Type
24+
*/
25+
26+
/**
27+
* Fallback {@link Decoder|decoder}.
1828
* @param {Reader|Uint8Array} readerOrBuffer Reader or buffer to decode from
1929
* @param {number} [length] Length of the message, if known beforehand
2030
* @returns {Message} Populated runtime message
@@ -85,9 +95,9 @@ decode.fallback = function decode_fallback(readerOrBuffer, length) {
8595
};
8696

8797
/**
88-
* Generates a decoder specific to the specified message type, with an identical signature to {@link codegen.decode.fallback}.
98+
* Generates a {@link Decoder|decoder} specific to the specified message type.
8999
* @param {Type} mtype Message type
90-
* @returns {CodegenInstance} {@link codegen|Codegen} instance
100+
* @returns {Codegen} Codegen instance
91101
*/
92102
decode.generate = function decode_generate(mtype) {
93103
/* eslint-disable no-unexpected-multiline */

src/codegen/encode.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ var Enum = require("../enum"),
1414
codegen = require("../codegen");
1515

1616
/**
17-
* Encodes a message of `this` message's type.
17+
* A message encoder as generated by {@link codegen.encode.generate}.
18+
* @typedef Encoder
19+
* @type {function}
20+
* @param {Message|Object} message Runtime message or plain object to encode
21+
* @param {Writer} [writer] Writer to encode to
22+
* @returns {Writer} writer
23+
* @this Type
24+
*/
25+
26+
/**
27+
* Fallback {@link Encoder|encoder}.
1828
* @param {Message|Object} message Runtime message or plain object to encode
1929
* @param {Writer} [writer] Writer to encode to
2030
* @returns {Writer} writer
@@ -93,9 +103,9 @@ encode.fallback = function encode_fallback(message, writer) {
93103
};
94104

95105
/**
96-
* Generates an encoder specific to the specified message type, with an identical signature to {@link codegen.encode.fallback}.
106+
* Generates an {@link Encoder|encoder} specific to the specified message type.
97107
* @param {Type} mtype Message type
98-
* @returns {CodegenInstance} {@link codegen|Codegen} instance
108+
* @returns {Codegen} Codegen instance
99109
*/
100110
encode.generate = function encode_generate(mtype) {
101111
/* eslint-disable no-unexpected-multiline */

src/codegen/verify.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ var Enum = require("../enum"),
1313
codegen = require("../codegen");
1414
var isInteger = util.isInteger;
1515

16+
/**
17+
* A message verifier as generated by {@link codegen.verify.generate}.
18+
* @typedef Verifier
19+
* @type {function}
20+
* @param {Message|Object} message Runtime message or plain object to verify
21+
* @returns {?string} `null` if valid, otherwise the reason why it is not
22+
* @this {Type}
23+
*/
24+
1625
function invalid(field, expected) {
1726
return "invalid value for field " + field.getFullName() + " (" + expected + (field.repeated && expected !== "array" ? "[]" : field.map && expected !== "object" ? "{k:"+field.keyType+"}" : "") + " expected)";
1827
}
@@ -93,7 +102,7 @@ function verifyKey(field, value) {
93102
}
94103

95104
/**
96-
* Verifies a runtime message of `this` message type.
105+
* Fallback {@link Verifier|verifier}.
97106
* @param {Message|Object} message Runtime message or plain object to verify
98107
* @returns {?string} `null` if valid, otherwise the reason why it is not
99108
* @this {Type}
@@ -230,9 +239,9 @@ function genVerifyKey(gen, field, ref) {
230239
}
231240

232241
/**
233-
* Generates a verifier specific to the specified message type, with an identical signature to {@link codegen.verify.fallback}.
242+
* Generates a {@link Verifier|verifier} specific to the specified message type.
234243
* @param {Type} mtype Message type
235-
* @returns {CodegenInstance} {@link codegen|Codegen} instance
244+
* @returns {Codegen} Codegen instance
236245
*/
237246
verify.generate = function verify_generate(mtype) {
238247
/* eslint-disable no-unexpected-multiline */

0 commit comments

Comments
 (0)