How to use the flatbuffers.compileSchema function in flatbuffers

To help you get started, we’ve selected a few flatbuffers 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 mtth / avsc / etc / benchmarks / js-serialization-libraries / index.js View on Github external
EncodeSuite.prototype.__flatbuffers = function (args) {
  var message = flatbuffers.compileSchema(fs.readFileSync(args));
  var val = this.getValue(true);
  return function () {
    var buf = Buffer.from(message.generate(val).buffer);
    if (!buf.length) {
      throw new Error();
    }
  };
};
github mtth / avsc / etc / benchmarks / js-serialization-libraries / index.js View on Github external
DecodeSuite.prototype.__flatbuffers = function (args) {
  var root = flatbuffers.compileSchema(fs.readFileSync(args));
  var buf = Buffer.from(root.generate(this.getValue()));
  return function () {
    var obj = root.parse(buf);
    if (obj.$) {
      throw new Error();
    }
  };
};