How to use the protocol-buffers-schema.parse function in protocol-buffers-schema

To help you get started, we’ve selected a few protocol-buffers-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mafintosh / protocol-buffers / index.js View on Github external
module.exports = function (proto, opts) {
  if (!opts) opts = {}
  if (!proto) throw new Error('Pass in a .proto string or a protobuf-schema parsed object')

  var sch = (typeof proto === 'object' && !Buffer.isBuffer(proto)) ? proto : schema.parse(proto)

  // to not make toString,toJSON enumarable we make a fire-and-forget prototype
  var Messages = function () {
    var self = this

    compile(sch, opts.encodings || {}).forEach(function (m) {
      self[m.name] = flatten(m.values) || m
    })
  }

  Messages.prototype.toString = function () {
    return schema.stringify(sch)
  }

  Messages.prototype.toJSON = function () {
    return sch
github mtth / avsc / etc / benchmarks / js-serialization-libraries / index.js View on Github external
DecodeSuite.prototype.__pbf = function (args) {
  var parts = args.split(':');
  var proto = pbSchema.parse(fs.readFileSync(parts[0]));
  var message = pbCompile(proto)[parts[1]];
  var pbf = new Pbf();
  message.write(this.getValue(true), pbf);
  var buf = pbf.finish();
  return function () {
    var obj = message.read(new Pbf(buf));
    if (obj.$) {
      throw new Error();
    }
  };
};
github evanw / pbjs / index.ts View on Github external
export function parseSchema(contents: string): ParsedSchema {
  const schema = parser.parse(contents);

  return {
    compile(): any {
      const result = {};
      new Function('exports', generate(schema))(result);
      return result;
    },

    toJavaScript({ es6 }: JsOptions = {}): string {
      return generate(schema, { es6 });
    },

    toTypeScript(): string {
      return generate(schema, { typescript: true });
    },
  };
github sparkswap / broker / broker-daemon / utils / grpc-gateway.js View on Github external
    .map(p => schema.parse(fs.readFileSync(p)))
    .forEach((sch, si) => {
github konsumer / grpc-dynamic-gateway / index.js View on Github external
    .map(p => schema.parse(fs.readFileSync(p)))
    .forEach((sch, si) => {

protocol-buffers-schema

No nonsense protocol buffers schema parser written in Javascript

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular protocol-buffers-schema functions