MCPcopy Create free account
hub / github.com/chrisdew/protobuf

github.com/chrisdew/protobuf @nodejs-0.8-0.10

Chat with this repo
repository ↗ · DeepWiki ↗ · release nodejs-0.8-0.10 ↗ · + Follow
3,128 symbols 8,253 edges 183 files 443 documented · 14% updated 6y agonodejs-6-7 · 2017-05-23★ 22912 open issues

Browse by type

Functions 2,656 Types & classes 472
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Node v0.11.13 Now Supported

Many thanks to Mário Freitas/imkira for his work.

Protobuf

This is a fork of http://code.google.com/p/protobuf-for-node/

It now works with the NodeJS 0.8.x and 0.10.x series.

To install, just type:

npm install protobuf

Thanks to work by seishun, it now uses node-gyp and has google's protocol bufferes library integrated, so no separate installtion required.

All the best,

Chris.

P.S. Breaking change in 0.8.6: uint64 and int64 are now read as Javascript Strings, rather than floating point numbers. They can still be set from Javascript Numbers (as well as from string).

P.P.S. Here's an example I did for https://github.com/chrisdew/protobuf/issues/29 - most users won't need the complication of bytes fields.

buftest.proto

package com.chrisdew.buftest;

message BufTest {
  optional float num  = 1;
  optional bytes payload = 2;
}

buftest.js

var fs = require('fs');
var Schema = require('protobuf').Schema;

// "schema" contains all message types defined in buftest.proto|desc.
var schema = new Schema(fs.readFileSync('buftest.desc'));

// The "BufTest" message.
var BufTest = schema['com.chrisdew.buftest.BufTest'];

var ob = { num: 42 };
ob.payload = new Buffer("Hello World");

var proto = BufTest.serialize(ob);
console.log('proto.length:', proto.length);

var outOb = BufTest.parse(proto);
console.log('unserialised:', JSON.stringify(outOb));

var payload = new Buffer(outOb.payload);
console.log(payload);

Makefile: (second line begins with a TAB not spaces)

all:
    protoc --descriptor_set_out=buftest.desc --include_imports buftest.proto

output:

$ node buftest.js 
proto.length: 18
unserialised: {"num":42,"payload":{"0":72,"1":101,"2":108,"3":108,"4":111,"5":32,"6":87,"7":111,"8":114,"9":108,"10":100,"length":11}}
payload: <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>

Older instructions for use with the NodeJS 0.6.x series.

Prerequisites:

NodeJS v0.6.X npm

To install on Ubuntu and OSX:

The first steps are to build and install Google's protobuf library. Make sure you have the right version by running "protoc --version" after the install.

wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
tar -xzvf protobuf-2.4.1.tar.gz
cd protobuf-2.4.1/
./configure && make && sudo make install
cd

This installs the npm package.

npm install protobuf

For Ubuntu, update library paths.

sudo ldconfig

For OSX, you might need to add the path:

export DYLD_LIBRARY_PATH=/home/chris/node_modules/protobuf/build/Release:/usr/local/lib:$DYLD_LIBRARY_PATH

And test that it works... Run node, try

require('protobuf');

you should see:

{ Schema: [Function: Schema] }

As seen from the instructions above, this is my first attempt at packaging a slightly complex C++ module for NPM.

If you can help me simplify these instructions, please submit a patch.

Good luck,

Chris.

Core symbols most depended-on inside this repo

Shape

Method 2,193
Function 463
Class 434
Enum 38

Languages

C++100%

Modules by API surface

protobuf/src/google/protobuf/descriptor.pb.h345 symbols
protobuf/src/google/protobuf/descriptor.cc156 symbols
protobuf/src/google/protobuf/repeated_field.h92 symbols
protobuf/src/google/protobuf/wire_format_lite_inl.h89 symbols
protobuf/src/google/protobuf/descriptor.pb.cc71 symbols
protobuf/src/google/protobuf/descriptor_unittest.cc65 symbols
protobuf/src/google/protobuf/stubs/common.h63 symbols
protobuf/src/google/protobuf/text_format.cc59 symbols
protobuf/src/google/protobuf/compiler/parser.cc57 symbols
protobuf/src/google/protobuf/compiler/plugin.pb.h55 symbols
protobuf/src/google/protobuf/descriptor.h54 symbols
example/protoservice.pb.h50 symbols

For agents

$ claude mcp add protobuf \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page