Socket
Socket
Sign inDemoInstall

protobuf

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protobuf - npm Package Compare versions

Comparing version 0.8.6 to 0.8.7

2

package.json
{ "name" : "protobuf",
"version" : "0.8.6",
"version" : "0.8.7",
"description" : "Protocol Buffers for NodeJS",

@@ -4,0 +4,0 @@ "author": {

@@ -18,5 +18,57 @@ This is a fork of http://code.google.com/p/protobuf-for-node/

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.

@@ -23,0 +75,0 @@ ========================================================

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc