Git Product home page Git Product logo

Comments (4)

chenxyzl avatar chenxyzl commented on June 4, 2024 1
let a = new SearchRequest();
a.result_per_page = "1111111"
// a.page_number = 1111111
console.log(a);
let b = SearchRequest.deserializeBinary(a.serializeBinary());
console.log(b);

from protoc-gen-ts.

thesayyn avatar thesayyn commented on June 4, 2024

I couldn't understand the question but from what you wrote I think you want to be able to create proto messages through an helper function. But this plugin does not generate any generic helper function to create proto messages. Instead, it generates a method in every single proto message. The method called as deserialize (similar to decode) and you can pass your unit8array to deserialize method in the particular message and could get the constructed (filled) message.

All you need to do is write a statement like this

MyProtoMessage.deserialize(new Uint8Array()) 

This statement will return an instance of MyProtoMessage that populated with the data you have passed in.

I hope this is clear for you.

Also, since the all proto messages have a deserialize method, you can write a generic helper function to construct as you wish.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on June 4, 2024

@GeTOUO Do you still have any questions in your mind?

from protoc-gen-ts.

thesayyn avatar thesayyn commented on June 4, 2024

I'm going to close this issue as resolved. Please feel free to reopen.

from protoc-gen-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.