How to use the Root function from protobufjs
Find comprehensive JavaScript protobufjs.Root code examples handpicked from public code repositorys.
130 131 132 133 134 135 136 137 138 139
const match = line.match(/(?:import "([^"]*)";|file:(.*proto),)/); return !match || protos.indexOf(match[1] || match[2]) >= 0; }).join('\n'); // 编译pbjs const root = new protobuf.Root(); root.loadSync(path.resolve(__dirname, './proto/dzhua.proto')); const parsed = protobuf.parse(msgContent, root); if (parsed.imports) { parsed.imports.forEach((name) => {
4
3
4
+ 17 other calls in file
GitHub: tianyk/note
13 14 15 16 17 18 19 20 21 22
``` ``` javascript const protobuf = require('protobufjs'); const root = protobuf.Root.fromJSON(require('bundle.json')); const AwesomeMessage = root.lookup('awesomepackage.AwesomeMessage'); var message = { id: 1,
2
8
3
+ 3 other calls in file
GitHub: alibaba-archive/antpb
6 7 8 9 10 11 12 13 14 15
const converter = require('./lib/converter'); const parse = require('./lib/parse'); const protobuf = require('protobufjs'); 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;
1
3
15
+ 14 other calls in file
20 21 22 23 24 25 26 27 28 29
const jsonTarget = require('./node_modules/protobufjs/cli/targets/json') const path = require('path') const fs = require('fs') let root = new protobuf.Root() let files = fs.readdirSync('./protos') .map(f => path.resolve('./protos', f)) .filter(f => f.endsWith('.proto'))
42
0
2
+ 9 other calls in file
140 141 142 143 144 145 146 147 148 149
*/ this.requestId = 1000; // 请求序列号,自增 this.isHandStop = false; this.root = protobufjs.Root.fromJSON(Pb); this.cacheResponseCallback = {}; // 缓存的回调函数 this.cacheNotifyCallback = {}; // 缓存的通知回调函数 this.header = null; // 缓存接收的数据包头
13
56
5
+ 5 other calls in file
GitHub: theFlyYun/yun
2 3 4 5 6 7 8 9 10 11 12 13
const protobuf = require('protobufjs'); const fs = require('fs'); const protoFilePath = '../../config/pbconfig/'; const path = require('path'); const root = protobuf.Root.fromJSON(require("../../config/pbconfig/protobufConfig.json")); const payloaddecode = require('../utils/payloadDecode') const opt = require("../../config/config.js").logger; const createLogger=require('../logs/logger')
1
0
0
58 59 60 61 62 63 64 65 66 67
const protoToSchema = ( protoPaths, schemaIdPrefix = DEFAULT_SCHEMA_ID_PREFIX, schemaIdSuffix = DEFAULT_SCHEMA_ID_SUFFIX, ) => { const root = new protobufjs.Root(); const protoSchema = (protobufjs.loadSync(protoPaths, root)).resolveAll(); const definitions = recursive(protoSchema, {}, '', schemaIdPrefix, schemaIdSuffix); return Object.keys(definitions).map(k => ({ $id: `${schemaIdPrefix}${k}${schemaIdSuffix}`,
0
3
2
+ 15 other calls in file
697 698 699 700 701 702 703 704 705 706
Object.defineProperty(exports, "__esModule", { value: true }); var pb = require("protobufjs"); var Protos = /** @class */ (function () { function Protos() { var _this = this; var root = new pb.Root({ root: "/proto3 versions", }); root.resolvePath = function (origin, file) { var str = this.options.root + "/" + file;
1
0
0
+ 2 other calls in file
20 21 22 23 24 25 26 27 28 29
exports.loadRoot = async () => { const protosPath = path.join(__dirname, '../protos'); const protos = await readdir(protosPath).then(files => files.map(name => path.join(protosPath, name)), ); const root = new Root(); return root.load(protos, { keepCase: true }); }; /**
1
0
5
2585 2586 2587 2588 2589 2590 2591 2592 2593 2594
* @see {@link Root#load} */ function load(filename, root, callback) { if (typeof root === "function") { callback = root; root = new protobuf.Root(); } else if (!root) root = new protobuf.Root(); return root.load(filename, callback); }
0
1
0
+ 8 other calls in file
46 47 48 49 50 51 52 53 54 55
const className = titleify(enumName) + 'Action'; return _.set(map, key, { enum: enumName, name: className }); }, {}); // Compile Protobufs const root = protobuf.Root.fromJSON(protoJson); const SCPayload = root.lookup('SCPayload'); const PropertyValue = root.lookup('PropertyValue'); const PropertySchema = root.lookup('PropertySchema'); const Location = root.lookup('Location');
0
1
3
GitHub: compactr/compactr.js
14 15 16 17 18 19 20 21 22 23
}); const mult = 32; const sizes = { json: 0, compactr: 0, protobuf: 0 }; let root = protobuf.Root.fromJSON({ nested: { IntBenchTest: { fields: { id: { type: 'uint32', id: 1 },
6
99
8
+ 3 other calls in file
GitHub: King5-12/xiu-cli
6 7 8 9 10 11 12 13 14 15 16 17
let isTs = true; var Service = protobufjs.Service, Enum = protobufjs.Enum, Namespace = protobufjs.Namespace, Root = protobufjs.Root; const option = { alternateCommentMode: true, };
0
0
1
+ 59 other calls in file
12 13 14 15 16 17 18 19 20 21 22
int32 age = 2; } `; // Create a Root instance to hold the schema const root = protobuf.Root.fromJSON({ nested: { Person: protobuf.parse(personSchema).root.lookupType('Person'), }, });
0
0
0
protobufjs.load is the most popular function in protobufjs (282 examples)