Giter Club home page Giter Club logo

protobuf-es's Introduction

Protobuf-ES

A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.

For example, the following definition:

message Person {
  string name = 1;
  int32 id = 2;  // Unique ID number for this person.
  string email = 3;
}

Is compiled to an ECMAScript class that can be used like this:

let pete = new Person({
  name: "pete",
  id: 123
});

let bytes = pete.toBinary();
pete = Person.fromBinary(bytes);
pete = Person.fromJsonString('{"name": "pete", "id": 123}');

To learn more, have a look at a complete code example, the documentation for the generated code, and the documentation for the runtime API.

How does this compare to protoc's JavaScript generator?

js_generator.cc is rarely updated, and has fallen behind the quickly moving world of JavaScript.

For example:

  • it does not support ECMAScript modules
  • it cannot generate TypeScript (3rd party plugins are necessary)
  • it does not support the canonical JSON format
  • it does not carry over comments from your .proto files

Because of this, we want to provide a solid, modern alternative with Protobuf-ES.

The main differences of the generated code:

  • we use plain properties for fields, where protoc uses getter and setter methods
  • we implement the canonical JSON format
  • we generate much smaller bundles
  • we rely on standard APIs instead of the Closure Library

See the migration guides for details.

What features are implemented

We implement all proto3 features, including the canonical JSON format.
We implement all proto2 features, except for extensions and the text format.
The implementation is covered by the protocol buffers conformance tests.

TypeScript

The minimum version of TypeScript supported by Protobuf-ES is 4.1.2.

Packages

Copyright

The code to encode and decode varint is Copyright 2008 Google Inc., licensed under BSD-3-Clause.
All other files are licensed under Apache-2.0, see LICENSE.

protobuf-es's People

Contributors

timostamm avatar smaye81 avatar dependabot[bot] avatar paul-sachs avatar fubhy avatar seankimdev avatar cyinma avatar yukukotani avatar buildbreaker avatar amckinney avatar kevpie avatar pkwarren avatar rubensf avatar tp avatar bufdev avatar

Watchers

James Cloos 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.