How to use the util function from protobufjs

Find comprehensive JavaScript protobufjs.util code examples handpicked from public code repositorys.

16
17
18
19
20
21
22
23
24
25
module.exports = require('./bundle.js');

// Allow client code to translate the obscure uint64 field format to/from a number
module.exports.numberToUint64 = protobuf.util.longToHash;
module.exports.uint64ToNumber = (uint64Value) => {
    const value = protobuf.util.longFromHash(uint64Value, true);
    return typeof value === 'number' ? value : value.toInt();
}

// Build the services
fork icon525
star icon774
watch icon63

+ 7 other calls in file

15
16
17
18
19
20
21
22
23
24
25
    OneOf = protobuf.OneOf,
    Enum = protobuf.Enum,
    Service = protobuf.Service,
    Method = protobuf.Method,
    types = protobuf.types,
    util = protobuf.util;


var base10Re = /^[1-9][0-9]*$/,
    base10NegRe = /^-?[1-9][0-9]*$/,
    base16Re = /^0[x][0-9a-fA-F]+$/,
fork icon6
star icon8
watch icon0

+ 3 other calls in file

9
10
11
12
13
14
15
16
17
18
19
const common = protobuf.common;
const Type = protobuf.Type;
const Root = protobuf.Root;
const Reader = protobuf.Reader;
const Writer = protobuf.Writer;
const util = protobuf.util;
const verifier = protobuf.verifier;
const wrappers = protobuf.wrappers;


const originalSetup = Type.prototype.setup;
fork icon1
star icon3
watch icon0

2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
/**
 * Reconfigures the library according to the environment.
 * @returns {undefined}
 */
function configure() {
    protobuf.util._configure();
    protobuf.Writer._configure(protobuf.BufferWriter);
    protobuf.Reader._configure(protobuf.BufferReader);
}

fork icon0
star icon1
watch icon0

+ 2 other calls in file

20
21
22
23
24
25
26
27
28
29
const root = new protobufjs.Root();
const paths = [];
// paths.push(path.relative(process.cwd(), path.join(__dirname, '..')) || '.');
paths.push(process.cwd());
root.resolvePath = (origin, target) => {
    const normOrigin = protobufjs.util.path.normalize(origin),
        normTarget = protobufjs.util.path.normalize(target);
    let resolved = protobufjs.util.path.resolve(
        normOrigin,
        normTarget,
fork icon0
star icon0
watch icon1

+ 119 other calls in file

264
265
266
267
268
269
270
271
272
273
//Make this prettier
try {
	this.realTimeData = this.GTFSRealTimeMessage.decode(buffer);
	this.realTimeLastModified = Number.parseInt(this.realTimeData.header.timestamp);
 } catch (e) {
	  if (e instanceof protobuf.util.ProtocolError) {
			console.error("Protocol buffer protocol error");
	  } else {
			console.error("Protocol buffer wire format is invalid");
	  }
fork icon0
star icon0
watch icon1

+ 29 other calls in file