@@ -151,12 +151,11 @@ var root = new Root().define("awesomepackage").add(AwesomeMessage);
151
151
152
152
``` js
153
153
...
154
- var Prototype = protobuf .Prototype ;
155
154
156
155
function AwesomeMessage (properties ) {
157
- Prototype .call (this , properties);
156
+ protobuf . Message .call (this , properties);
158
157
}
159
- protobuf .inherits (AwesomeMessage, root .lookup (" awesomepackage.AwesomeMessage" ) /* or use reflection */ );
158
+ protobuf .Class . create ( root .lookup (" awesomepackage.AwesomeMessage" ) /* or use reflection */ , AwesomeMessage );
160
159
161
160
var message = new AwesomeMessage ({ awesomeField: " AwesomeString" });
162
161
@@ -203,6 +202,8 @@ function rpcImpl(method, requestData, callback) {
203
202
}
204
203
```
205
204
205
+ There is also an [ example for streaming RPC] ( https://github.com/dcodeIO/protobuf.js/blob/master/examples/streaming-rpc.js ) .
206
+
206
207
### Usage with TypeScript
207
208
208
209
``` ts
@@ -218,8 +219,11 @@ The library exports a flat `protobuf` namespace with the following members, orde
218
219
219
220
### Parser
220
221
221
- * ** load(filename: ` string|Array ` , [ root: ` Root ` ] , [ callback: ` function(err: Error, [root: Root]) ` ] ): ` Promise ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
222
- Loads one or multiple .proto files into the specified root or creates a new one when omitted.
222
+ * ** load(filename: ` string|Array ` , [ root: ` Root ` ] , [ callback: ` function(err: Error, [root: Root]) ` ] ): ` Promise|undefined ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
223
+ Loads one or multiple .proto or preprocessed .json files into a common root namespace.
224
+
225
+ * ** loadSync(filename: ` string|string[] ` , [ root: ` Root ` ] ): ` Root ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
226
+ Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).
223
227
224
228
* ** tokenize(source: ` string ` ): ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/tokenize.js )] <br />
225
229
Tokenizes the given .proto source and returns an object with useful utility functions.
@@ -256,14 +260,8 @@ The library exports a flat `protobuf` namespace with the following members, orde
256
260
* ** BufferReader** _ extends ** Reader** _ [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/reader.js )] <br />
257
261
Wire format reader using node buffers.
258
262
259
- * ** Encoder** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/encoder.js )] <br />
260
- Wire format encoder using code generation on top of reflection.
261
-
262
- * ** Decoder** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/decoder.js )] <br />
263
- Wire format decoder using code generation on top of reflection.
264
-
265
- * ** Verifier** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/verifier.js )] <br />
266
- Runtime message verifier using code generation on top of reflection.
263
+ * ** codegen** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/codegen.js )] <br />
264
+ A closure for generating functions programmatically.
267
265
268
266
### Reflection
269
267
@@ -296,22 +294,25 @@ The library exports a flat `protobuf` namespace with the following members, orde
296
294
297
295
### Runtime
298
296
299
- * ** inherits(clazz: ` Function ` , type: ` Type ` , [ options: ` Object.<string,*> ` ] ): ` Prototype ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/inherits .js )] <br />
300
- Inherits a custom class from the message prototype of the specified message type .
297
+ * ** Class ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/class .js )] <br />
298
+ Runtime class providing the tools to create your own custom classes .
301
299
302
- * ** Prototype ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/prototype .js )] <br />
303
- Runtime message prototype ready to be extended by custom classes or generated code .
300
+ * ** Message ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/message .js )] <br />
301
+ Abstract runtime message .
304
302
305
303
### Utility
306
304
307
- * ** util : ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/util .js )] <br />
308
- Utility functions .
305
+ * ** types : ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/types .js )] <br />
306
+ Common type constants .
309
307
310
308
* ** common(name: ` string ` , json: ` Object ` )** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/common.js )] <br />
311
309
Provides common type definitions.
312
310
313
- * ** types: ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/types.js )] <br />
314
- Common type constants.
311
+ * ** rpc: ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/rpc.js )] <br />
312
+ Streaming RPC helpers.
313
+
314
+ * ** util: ` Object ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/util.js )] <br />
315
+ Various utility functions.
315
316
316
317
Documentation
317
318
-------------
@@ -320,22 +321,6 @@ Documentation
320
321
321
322
* [ protobuf.js API Documentation] ( http://dcode.io/protobuf.js/ )
322
323
323
- ### Data type recommendations
324
-
325
- | Value type | protobuf Type | Size / Notes
326
- |---------------------|---------------|-----------------------------------------------------------------------------------
327
- | Unsigned 32 bit int | uint32 | 1 to 5 bytes.
328
- | Signed 32 bit int | sint32 | 1 to 5 bytes. Do not use int32 (always encodes negative values as 10 bytes).
329
- | Unsigned 52 bit int | uint64 | 1 to 10 bytes.
330
- | Signed 52 bit int | sint64 | 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
331
- | Unsigned 64 bit int | uint64 | Use with long.js. 1 to 10 bytes.
332
- | Signed 64 bit int | sint64 | Use with long.js. 1 to 10 bytes. Do not use int64 (always encodes negative values as 10 bytes).
333
- | 32 bit float | float | 4 bytes.
334
- | 64 bit float | double | 8 bytes. Use float if 32 bits of precision are enough.
335
- | Boolean values | bool | 1 byte.
336
- | Strings | string | 1 to 5 bytes + utf8 byte length.
337
- | Buffers | bytes | 1 to 5 bytes + byte length.
338
-
339
324
Command line
340
325
------------
341
326
0 commit comments