How to use the parse function from protobufjs
Find comprehensive JavaScript protobufjs.parse code examples handpicked from public code repositorys.
44 45 46 47 48 49 50 51 52 53
describe('Protobuf encoding', function () { var expectedArray = [0x0a, 0x0d, 0x41, 0x77, 0x65, 0x73, 0x6f, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67]; var expectedBuffer = Buffer.from(expectedArray); it("Encodes a proto message", function () { root = protobuf.parse(myMsg).root; // Obtain a message type var AwesomeMessage = root.lookupType(".awesomepackage.AwesomeMessage"); var payload = { awesomeField: "AwesomeString" };
26
15
16
+ 24 other calls in file
GitHub: agreatfool/SASDN
0 1 2 3 4 5 6 7 8 9 10 11 12
// 该文件来自:https://github.com/dcodeIO/protobuf.js/blob/master/src/parse.js // 查找自定义代码请搜索字符串:"CHANGED" const protobuf = require('protobufjs'); const parse = protobuf.parse; parse.filename = null; parse.defaults = {keepCase: false};
6
8
0
+ 3 other calls in file
132 133 134 135 136 137 138 139 140 141
}).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) => { const absolutePath = path.resolve(__dirname, './proto', name); root.loadSync(absolutePath);
4
3
4
+ 17 other calls in file
3 4 5 6 7 8 9 10 11
const _ = require('lodash'); describe('message-generator', () => { it('should generate a message', () => { const givenProto = protobuf.parse(` syntax = "proto3"; package a.test;
1
0
65
+ 31 other calls in file
832 833 834 835 836 837 838 839 840 841
* Create gRPC client stib * @param {Object} options from gRPC client */ module.exports.grpcQuery = async (options) => { const { grpcUrl, grpcProtobufData, grpcServiceName, grpcEnableTls, grpcMethod, grpcBody } = options; const protocObject = protojs.parse(grpcProtobufData); const protoServiceObject = protocObject.root.lookupService(grpcServiceName); const Client = grpc.makeGenericClientConstructor({}); const credentials = grpcEnableTls ? grpc.credentials.createSsl() : grpc.credentials.createInsecure(); const client = new Client(
0
0
3
+ 3 other calls in file
14 15 16 17 18 19 20 21 22 23 24 25
`; // Create a Root instance to hold the schema const root = protobuf.Root.fromJSON({ nested: { Person: protobuf.parse(personSchema).root.lookupType('Person'), }, }); // Create a new message object and set its fields
0
0
0
GitHub: ToolJet/ToolJet
94 95 96 97 98 99 100 101 102 103
const foreignKey = table.foreignKeys.find((fk) => fk.columnNames.indexOf(columnName) !== -1); await queryRunner.dropForeignKey(tableName, foreignKey); } export async function getServiceAndRpcNames(protoDefinition) { const root = protobuf.parse(protoDefinition).root; const serviceNamesAndMethods = root.nestedArray .filter((item) => item instanceof protobuf.Service) .reduce((acc, service) => { const rpcMethods = service.methodsArray.map((method) => method.name);
0
0
147
protobufjs.load is the most popular function in protobufjs (282 examples)