Git Product home page Git Product logo

protobuf-ts's Introduction

protobuf-ts <timostamm> npm

Protocol buffers and RPC for Node.js and the Web Browser. Pure TypeScript.

For the following .proto file:

syntax = "proto3";

message Person {
    string name = 1;
    uint64 id = 2;
    int32 years = 3;
    optional bytes data = 5;
}

protobuf-ts generates code that can be used like this:

let pete: Person = {
    name: "pete", 
    id: 123n, // it's a bigint
    years: 30
    // data: new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]);
};

let bytes = Person.toBinary(pete);
pete = Person.fromBinary(bytes);

pete = Person.fromJsonString('{"name":"pete", "id":"123", "years": 30}')

What are protocol buffers?

Protocol buffers is an interface definition language and binary serialization format.
Data structures defined in .proto files are platform-independent and can be used in many languages.
To learn more about the capabilities, please check the official language guide.

Quickstart

  • npm install @protobuf-ts/plugin

    installs the plugin and the compiler "protoc"

  • download the example file msg-readme.proto and place it into a protos/ directory

  • npx protoc --ts_out . --proto_path protos protos/msg-readme.proto

    generates msg-readme.ts
    if your protoc version asks for it, add the flag "--experimental_allow_proto3_optional"

Features

Read the MANUAL to learn more.

Copyright

Support

Buy Me A Coffee

protobuf-ts's People

Contributors

be9 avatar colinlaws avatar commanderroot avatar deini avatar dependabot-preview[bot] avatar dependabot[bot] avatar ekazim avatar eyalpost avatar fenos avatar gtb3nw avatar jamesbirtles avatar jcready avatar kskalski avatar lqs avatar lyh543 avatar markh123 avatar mikeylemmon avatar odashevskii-plaid avatar pedelman avatar ryotasugawara avatar sessfeld avatar tannera avatar timostamm avatar vicb avatar whs avatar wielski avatar

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.