package
No nonsense protocol buffers schema parser written in Javascript
npm install protocol-buffers-schemaGitHub-flavored package documentation.
Across all versions, last 30 days.
56,144,790 in 30 days
Runtime metadata.
Tagged topics.
No nonsense protocol buffers schema parser written in Javascript
npm install protocol-buffers-schemaFirst save the following file as example.proto
syntax = "proto2";
message Point {
required int32 x = 1;
required int32 y=2;
optional string label = 3;
}
message Line {
required Point start = 1;
required Point end = 2;
optional string label = 3;
}The run the following example
var fs = require('fs')
var schema = require('protocol-buffers-schema')
// pass a buffer or string to schema.parse
var sch = schema.parse(fs.readFileSync('example.proto'))
// will print out the schema as a javascript object
console.log(sch)Running the above example will print something like
{
syntax: 2,
package: null,
enums: [],
messages: [{
name: 'Point',
enums: [],
messages: [],
options: {},
fields: [{
name: 'x',
type: 'int32',
tag: 1,
required: true,
repeated: false,
options: {}
}, {
name: 'y',
type: 'int32',
tag: 2,
required: true,
repeated: false
schema.parse(protobufSchemaBufferOrString)Parses a .proto schema into a javascript object
schema.stringify(schema)Stringifies a parsed schema back into .proto format
MIT
Estimated unpacked size across 1 packages.
67.3 kB
Includes dependencies.