Pure node.js Google Protocol Buffers implementation
npm install gpbNode-gpb
========
[![NPM version][NPM version image]][NPM version URL] [![Build status][Build status image]][Build status URL]
-----
[Google Protocol Buffers] pure JavaScript implementation for [node.js].
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism
for serializing structured data – think XML, but smaller, faster, and simpler.
You define how you want your data to be structured once, then you can use
special generated source code to easily write and read your structured data
to and from a variety of data streams and using a variety of languages – Java, C++, or Python.
And now Google Protocol Buffers are available in node.js without compiling binary addons!
This module has been tested with node.js versions 0.8.26, 0.10.22 and 0.11.9.
Based on [prtbfr.php] by Gaetano Giunta.
Check out the [Github repo] for the source code.
[Google Protocol Buffers]: https://developers.google.com/protocol-buffers/
[node.js]: http://nodejs.org/
[NPM version image]: https://badge.fury.io/js/gpb.png
[NPM version URL]: http://badge.fury.io/js/gpb
[Build status image]: https://secure.travis-ci.org/Sannis/node-gpb.png?branch=master
[Build status URL]: http://travis-ci.org/Sannis/node-gpb
[prtbfr.php]: https://github.com/gggeek/pinba_php/blob/master/lib/prtbfr.php
[Github repo]: https://github.com/Sannis/node-gpb
Installation
------------
You can install this module via [npm]:
$> npm install gpb
No specific libraries are needed because this is pure node.js module, not a binary addon.
[npm]: https://github.com/isaacs/npm
Usage
-----
``js
var GPB = require('gpb');
var proto = {
1: ["field_string", GPB.STRING, GPB.REQUIRED],
2: ["field_double", GPB.DOUBLE, GPB.OPTIONAL],
3: ["field_floats", GPB.FLOAT, GPB.REPEATED],
};
var data = {
"field_string": "Some string",
"field_double": 2e30,
"field_floats": [
1.1,
2.2,
3.3
]
};
var expected_encoded_data_length = GPB.encoded_length(data, proto);
var encoded_data = new Buffer(expected_encoded_data_length);
var actual_encoded_data_length = GPB.encode(encoded_data, 0/offset/, data, proto);
``
Contributing
------------
To contribute any patches, simply fork this repository using GitHub
and send a pull request to me. Thanks!
License
-------
MIT license. See license text in file LICENSE.
