1.4.1 • Published 3 years ago

node_protoc2 v1.4.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

node_protoc2

Wrap grpc-tools with additional ability that compile protobuf 64-int types to string automatically

Why

The official table that shows the type specified in the .proto file and the corresponding type in target program language doesn't include the JavaScript example. So here is:

.proto TypeJavaScript
double, float, int32,uint32,sint32,fixed32,sfixed32number
int64,uint64,sint64,fixed64,sfixed64number (maybe overflow)
boolboolean
stringstring
byteUint8Array

By default the official compiler protoc will compile all protobuf 64-int types into the JavaScript number type that maybe would cause overflow.

To work around this, you need to adding jstype annotation for every 64-int field because protoc doesn't provide any global compile option. Somehow this is annoying when the .proto files are not maintained by other teams.

So, I wrote this tool to make it easy.

Usage

You can generate static codes in JavaScript from .proto files through the following command:

npx node_protoc2 --out_dir output_folder foo.proto

All proto 64-int types would be compiled into JavaScript string type

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago