How to use the protobufjs.convertFieldsToCamelCase function in protobufjs

To help you get started, we’ve selected a few protobufjs 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 bazelbuild / rules_nodejs / internal / tsc_wrapped / worker.ts View on Github external
import * as path from 'path';
/* tslint:disable:no-require-imports */
const protobufjs = require('protobufjs');
const ByteBuffer = require('bytebuffer');

protobufjs.convertFieldsToCamelCase = true;

const DEBUG = false;

export function debug(...args: Array<{}>) {
  if (DEBUG) console.error.apply(console, args);
}

/**
 * Write a message to stderr, which appears in the bazel log and is visible to
 * the end user.
 */
export function log(...args: Array<{}>) {
  console.error.apply(console, args);
}

export function runAsWorker(args: string[]) {
github balthazar / csgo-float / protos / index.js View on Github external
const protobuf = require('protobufjs')
const path = require('path')

const builder = protobuf.newBuilder()

protobuf.convertFieldsToCamelCase = false
protobuf.loadProtoFile(path.join(__dirname, '/base_gcmessages.proto'), builder)
protobuf.loadProtoFile(path.join(__dirname, '/gcsdk_gcmessages.proto'), builder)
protobuf.loadProtoFile(path.join(__dirname, '/cstrike15_gcmessages.proto'), builder)

module.exports = builder.build()
github joshuaferrara / node-csgo / helpers / protos.js View on Github external
var Protobuf = require('protobufjs');

Protobuf.convertFieldsToCamelCase = false;

var builder = Protobuf.newBuilder();

Protobuf.loadProtoFile(__dirname + "/../protos/base_gcmessages.proto", builder);
Protobuf.loadProtoFile(__dirname + "/../protos/gcsdk_gcmessages.proto", builder);
Protobuf.loadProtoFile(__dirname + "/../protos/cstrike15_gcmessages.proto", builder);
Protobuf.loadProtoFile(__dirname + "/../protos/custom.proto", builder);
module.exports = builder.build();

var builder_steam = Protobuf.newBuilder();
Protobuf.loadProtoFile(__dirname + "/../protos/steammessages_clientserver.proto", builder_steam);
Protobuf.loadProtoFile(__dirname + "/../protos/steammessages_clientserver_2.proto", builder_steam);
module.exports.schema = builder_steam.build();
github grpc / grpc-node / packages / grpc-native-core / index.js View on Github external
exports.load = util.deprecate(function load(filename, format, options) {
  const ProtoBuf = require('protobufjs');
  options = Object.assign({}, common.defaultGrpcOptions, options);
  options.protobufjsVersion = 5;
  if (!format) {
    format = 'proto';
  }
  var convertFieldsToCamelCaseOriginal = ProtoBuf.convertFieldsToCamelCase;
  if(options && options.hasOwnProperty('convertFieldsToCamelCase')) {
    ProtoBuf.convertFieldsToCamelCase = options.convertFieldsToCamelCase;
  }
  var builder;
  try {
    switch(format) {
      case 'proto':
      builder = ProtoBuf.loadProtoFile(filename);
      break;
      case 'json':
      builder = ProtoBuf.loadJsonFile(filename);
      break;
      default:
      throw new Error('Unrecognized format "' + format + '"');
    }
  } finally {
    ProtoBuf.convertFieldsToCamelCase = convertFieldsToCamelCaseOriginal;
  }
github saul / demofile / net.js View on Github external
'use strict';

var _ = require('lodash');
var assert = require('assert');
var ProtoBuf = require('protobufjs');
var util = require('util');
var path = require('path');

ProtoBuf.convertFieldsToCamelCase = true;
var builder = ProtoBuf.loadProtoFile(path.resolve(__dirname, 'protobufs/cstrike15_usermessages.proto')).build();
assert(builder !== null);

function enumNetNameToClassName(enumName) {
  var type = enumName.slice(0, 3);
  assert(['net', 'svc'].indexOf(type) !== -1, 'unexpected message type');

  return util.format('C%sMsg_%s', type.toUpperCase(), enumName.slice(4));
}

function enumUMNameToClassName(enumName) {
  return util.format('CCSUsrMsg_%s', enumName.slice(6));
}

function processMessageEnum(messages, enumNameConverterFunc) {
  return _.chain(_.invert(messages))
github grpc / grpc-node / packages / grpc-native-core / index.js View on Github external
exports.load = util.deprecate(function load(filename, format, options) {
  const ProtoBuf = require('protobufjs');
  options = Object.assign({}, common.defaultGrpcOptions, options);
  options.protobufjsVersion = 5;
  if (!format) {
    format = 'proto';
  }
  var convertFieldsToCamelCaseOriginal = ProtoBuf.convertFieldsToCamelCase;
  if(options && options.hasOwnProperty('convertFieldsToCamelCase')) {
    ProtoBuf.convertFieldsToCamelCase = options.convertFieldsToCamelCase;
  }
  var builder;
  try {
    switch(format) {
      case 'proto':
      builder = ProtoBuf.loadProtoFile(filename);
      break;
      case 'json':
      builder = ProtoBuf.loadJsonFile(filename);
      break;
      default:
      throw new Error('Unrecognized format "' + format + '"');
    }
  } finally {
github bmavity / ges-client / tcp / messageParser.js View on Github external
var path = require('path')
	, uuid = require('node-uuid')
	, protobuf = require('protobufjs')

protobuf.convertFieldsToCamelCase = true
protobuf.populateAccessors = false

var builder = protobuf.loadProtoFile(path.resolve(__dirname, 'ges_client.proto'))
	, messageNamespace = 'EventStore.Client.Messages.' 
	, messages = builder.build('EventStore').Client.Messages

module.exports = {
	parse: parse
, serialize: serialize
}

function getMessageClass(messageName) {
	return messages[messageName]
}

function parse(messageName, payload) {