This is a fork of protobuf-for-node.
- Fixed to be compatible with node 0.6.
but
- Removed protoservice example.
- Removed native interface.
Otherwise it wouldn't compile.
-
Write proto file(s)
-
Generate desc file from proto file(s) with
protoc --descriptor_set_out ...
-
Use desc files from your scripts like this:
var fs = require('fs'), Schema = require('..').Schema; var schema = new Schema(fs.readFileSync(__dirname + '/feeds.desc')); var Feed = schema['feeds.Feed']; var serialized = Feed.serialize({ title: 'Title', ignored: 42 }); console.log('Serialized:', serialized); var aFeed = Feed.parse(serialized); console.log('Parsed:', aFeed);
-
Output:
Serialized: <SlowBuffer 0a 05 54 69 74 6c 65> Parsed: { title: 'Title' }