How to use the protobufjs/minimal.util 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 nars-dev / nars / packages / nars / src / NarsServer.ts View on Github external
decoded.call &&
              typeof decoded.call.messageId === "number"
            ) {
              NarsReconciler.invokeCallback({
                container,
                messageId: decoded.call.messageId,
                args: decoded.call.args ? decoded.call.args : {}
              });
            }
            break;
          default:
            console.error("Unreachable");
            break;
        }
      } catch (e) {
        if (e instanceof protobuf.util.ProtocolError) {
          // e.instance holds the so far decoded message with missing required fields
        } else {
          // wire format is invalid
        }
      }
    });
  });
github Bit-Nation / BITNATION-Pangea-mobile / src / services / upstream / compiledReqeust.js View on Github external
/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/
"use strict";

var $protobuf = require("protobufjs/minimal");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.api_proto = (function() {

    /**
     * Namespace api_proto.
     * @exports api_proto
     * @namespace
     */
    var api_proto = {};

    api_proto.Request = (function() {

        /**
github jnordberg / wsrpc / examples / painter / contents / protocol.js View on Github external
/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/
"use strict";

var $protobuf = require("protobufjs/minimal");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.Painter = (function() {

    /**
     * Constructs a new Painter service.
     * @exports Painter
     * @classdesc Represents a Painter
     * @extends $protobuf.rpc.Service
     * @constructor
     * @param {$protobuf.RPCImpl} rpcImpl RPC implementation
     * @param {boolean} [requestDelimited=false] Whether requests are length-delimited
     * @param {boolean} [responseDelimited=false] Whether responses are length-delimited
     */
github apollographql / apollo-server / packages / apollo-engine-reporting-protobuf / src / index.js View on Github external
const protobuf = require('./protobuf');
const protobufJS = require('protobufjs/minimal');

// Remove Long support.  Our uint64s tend to be small (less
// than 104 days).
// https://github.com/protobufjs/protobuf.js/issues/1253
protobufJS.util.Long = undefined;
protobufJS.configure();

// Override the generated protobuf Traces.encode function so that it will look
// for Traces that are already encoded to Buffer as well as unencoded
// Traces. This amortizes the protobuf encoding time over each generated Trace
// instead of bunching it all up at once at sendReport time. In load tests, this
// change improved p99 end-to-end HTTP response times by a factor of 11 without
// a casually noticeable effect on p50 times. This also makes it easier for us
// to implement maxUncompressedReportSize as we know the encoded size of traces
// as we go.
const originalTracesEncode = protobuf.Traces.encode;
protobuf.Traces.encode = function(message, originalWriter) {
  const writer = originalTracesEncode(message, originalWriter);
  const encodedTraces = message.encodedTraces;
  if (encodedTraces != null && encodedTraces.length) {
    for (let i = 0; i < encodedTraces.length; ++i) {
github irisnet / irisnet-crypto / chains / iris / tx / tx.js View on Github external
Input.prototype.toJSON = function toJSON() {
                return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
            };
github Bit-Nation / BITNATION-Pangea-mobile / src / services / upstream / compiledReqeust.js View on Github external
ShowModal.prototype.toJSON = function toJSON() {
                return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
            };