You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating a proto file to a js file, each proto defines it's own methods
Example
Record.decode=functiondecode(reader,length){if(!(readerinstanceof$Reader))reader=$Reader.create(reader);varend=length===undefined ? reader.len : reader.pos+length,message=new$root.Protos.Record();while(reader.pos<end){vartag=reader.uint32();switch(tag>>>3){case1: {message.key=reader.string();break;}case2: {message.value=reader.string();break;}default:
reader.skipType(tag&7);break;}}returnmessage;};/** * Decodes a Record message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof Protos.Record * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {Protos.Record} Record * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */Record.decodeDelimited=functiondecodeDelimited(reader){if(!(readerinstanceof$Reader))reader=new$Reader(reader);returnthis.decode(reader,reader.uint32());};/** * Verifies a Record message. * @function verify * @memberof Protos.Record * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */Record.verify=functionverify(message){if(typeofmessage!=="object"||message===null)return"object expected";if(message.key!=null&&message.hasOwnProperty("key"))if(!$util.isString(message.key))return"key: string expected";if(message.value!=null&&message.hasOwnProperty("value"))if(!$util.isString(message.value))return"value: string expected";returnnull;};/** * Creates a Record message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof Protos.Record * @static * @param {Object.<string,*>} object Plain object * @returns {Protos.Record} Record */Record.fromObject=functionfromObject(object){if(objectinstanceof$root.Protos.Record)returnobject;varmessage=new$root.Protos.Record();if(object.key!=null)message.key=String(object.key);if(object.value!=null)message.value=String(object.value);returnmessage;};/** * Creates a plain object from a Record message. Also converts values to other types if specified. * @function toObject * @memberof Protos.Record * @static * @param {Protos.Record} message Record * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */Record.toObject=functiontoObject(message,options){if(!options)options={};varobject={};if(options.defaults){object.key="";object.value="";}if(message.key!=null&&message.hasOwnProperty("key"))object.key=message.key;if(message.value!=null&&message.hasOwnProperty("value"))object.value=message.value;returnobject;};/** * Converts this Record to JSON. * @function toJSON * @memberof Protos.Record * @instance * @returns {Object.<string,*>} JSON object */Record.prototype.toJSON=functiontoJSON(){returnthis.constructor.toObject(this,$protobuf.util.toJSONOptions);};
This seems counterproductive and makes for some wasted space
This package could define a base class and use class inheritance
It would also allow the use of generic in typescript because right now, none of the protos are related to each other in any way
The text was updated successfully, but these errors were encountered:
When generating a proto file to a js file, each proto defines it's own methods
Example
This seems counterproductive and makes for some wasted space
This package could define a base class and use class inheritance
It would also allow the use of generic in typescript because right now, none of the protos are related to each other in any way
The text was updated successfully, but these errors were encountered: