@@ -191,7 +191,7 @@ greeter.sayHello({ name: 'you' }, function(err, response) {
191191});
192192```
193193
194- To make this work, all you have to do is provide an ` rpcImpl ` , which is is an asynchronous function that takes the reflected service method, the binary HelloRequest and a node-style callback as its parameters. For example:
194+ To make this work, all you have to do is provide an ` rpcImpl ` , which is an asynchronous function that takes the reflected service method, the binary HelloRequest and a node-style callback as its parameters. For example:
195195
196196``` js
197197function rpcImpl (method , requestData , callback ) {
@@ -219,7 +219,7 @@ The library exports a flat `protobuf` namespace with the following members, orde
219219
220220### Parser
221221
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 />
222+ * ** load(filename: ` string|string[] ` , [ root: ` Root ` ] , [ callback: ` function(err: Error, [root: Root]) ` ] ): ` Promise|undefined ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
223223 Loads one or multiple .proto or preprocessed .json files into a common root namespace.
224224
225225* ** loadSync(filename: ` string|string[] ` , [ root: ` Root ` ] ): ` Root ` ** [[ source] ( https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js )] <br />
@@ -234,10 +234,10 @@ The library exports a flat `protobuf` namespace with the following members, orde
234234 * ** package: ` string|undefined ` ** <br />
235235 The package name, if declared.
236236
237- * ** imports: ` Array |undefined` ** <br />
237+ * ** imports: ` string[] |undefined` ** <br />
238238 File names of imported files, if any.
239239
240- * ** weakImports: ` Array |undefined` ** <br />
240+ * ** weakImports: ` string[] |undefined` ** <br />
241241 File names of weakly imported files, if any.
242242
243243 * ** syntax: ` string|undefined ` ** <br />
@@ -413,33 +413,33 @@ The package includes a benchmark that tries to compare performance to native JSO
413413```
414414benchmarking encoding performance ...
415415
416- Type.encode to buffer x 471,717 ops/sec ±1.30 % (91 runs sampled)
417- JSON.stringify to string x 310,406 ops/sec ±1.00 % (90 runs sampled)
418- JSON.stringify to buffer x 172,766 ops/sec ±1.20 % (84 runs sampled)
416+ Type.encode to buffer x 479,876 ops/sec ±0.64 % (92 runs sampled)
417+ JSON.stringify to string x 311,489 ops/sec ±0.84 % (87 runs sampled)
418+ JSON.stringify to buffer x 175,079 ops/sec ±1.48 % (82 runs sampled)
419419
420420 Type.encode to buffer was fastest
421- JSON.stringify to string was 34.0 % slower
422- JSON.stringify to buffer was 63.3 % slower
421+ JSON.stringify to string was 35.2 % slower
422+ JSON.stringify to buffer was 63.8 % slower
423423
424424benchmarking decoding performance ...
425425
426- Type.decode from buffer x 1,285,867 ops/sec ±0.70 % (90 runs sampled)
427- JSON.parse from string x 292,106 ops/sec ±1.00 % (89 runs sampled)
428- JSON.parse from buffer x 259,361 ops/sec ±0.92 % (90 runs sampled)
426+ Type.decode from buffer x 1,267,612 ops/sec ±1.18 % (90 runs sampled)
427+ JSON.parse from string x 291,707 ops/sec ±1.12 % (92 runs sampled)
428+ JSON.parse from buffer x 262,640 ops/sec ±0.77 % (89 runs sampled)
429429
430430 Type.decode from buffer was fastest
431- JSON.parse from string was 77.4 % slower
432- JSON.parse from buffer was 79.9 % slower
431+ JSON.parse from string was 77.0 % slower
432+ JSON.parse from buffer was 79.2 % slower
433433
434434benchmarking combined performance ...
435435
436- Type to/from buffer x 238,382 ops/sec ±0.96 % (89 runs sampled)
437- JSON to/from string x 127,352 ops/sec ±0.73 % (93 runs sampled)
438- JSON to/from buffer x 89,593 ops/sec ±0.85 % (87 runs sampled)
436+ Type to/from buffer x 248,897 ops/sec ±0.89 % (90 runs sampled)
437+ JSON to/from string x 126,848 ops/sec ±0.75 % (92 runs sampled)
438+ JSON to/from buffer x 89,854 ops/sec ±0.79 % (93 runs sampled)
439439
440440 Type to/from buffer was fastest
441- JSON to/from string was 46.5 % slower
442- JSON to/from buffer was 62.4 % slower
441+ JSON to/from string was 49.0 % slower
442+ JSON to/from buffer was 63.9 % slower
443443```
444444
445445Note that JSON is a native binding nowadays and as such is about as fast as it possibly can get. So, how can protobuf.js be faster?
0 commit comments