Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protocol-buffers

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protocol-buffers - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

5

bench/index.js

@@ -1,3 +0,4 @@

var protobuf = require('../require')
var messages = protobuf('./bench.proto')
var protobuf = require('../')
var fs = require('fs')
var messages = protobuf(fs.readFileSync(__dirname + '/bench.proto'))

@@ -4,0 +5,0 @@ var TIMES = 1000000

46

compile.js

@@ -350,7 +350,16 @@ var encodings = require('./encodings')

// compile proto
// compile decode
var Message = genfun()
var invalid = m.fields
.map(function(f, i) {
return f.required && '!found'+i
})
.filter(function(f) {
return f
})
.join(' || ')
Message('function Message() {')
var decode = genfun()
var objectKeys = []
forEach(function(e, f) {

@@ -363,6 +372,6 @@ var def = f.options && f.options.default

if (f.repeated) {
Message('%s = []', genobj('this', f.name))
objectKeys.push(genobj.property(f.name) + ': []')
} else {
def = (def && def in vals) ? vals[def] : vals[Object.keys(vals)[0]]
Message('%s = %s', genobj('this', f.name), ''+parseInt(def || 0))
objectKeys.push(genobj.property(f.name) + ': ' + parseInt(def || 0))
}

@@ -373,22 +382,7 @@ return

if (!f.oneof) {
Message('%s = %s', genobj('this', f.name), defaultValue(f, def))
objectKeys.push(genobj.property(f.name) + ': ' + defaultValue(f, def))
}
})
Message('}')
Message = Message.toFunction()
// compile decode
var invalid = m.fields
.map(function(f, i) {
return f.required && '!found'+i
})
.filter(function(f) {
return f
})
.join(' || ')
var decode = genfun()
decode()

@@ -400,4 +394,10 @@ ('function decode(buf, offset, end) {')

('var oldOffset = offset')
('var obj = new Message()')
('var obj = {')
objectKeys.forEach(function (prop, i) {
decode(prop + (i === objectKeys.length - 1 ? '' : ','))
})
decode('}')
forEach(function(e, f, val, i) {

@@ -473,3 +473,2 @@ if (f.required) decode('var found%d = false', i)

decode = decode.toFunction({
Message: Message,
varint: varint,

@@ -480,3 +479,2 @@ skip: skip,

// end of compilation - return all the things

@@ -483,0 +481,0 @@

{
"name": "protocol-buffers",
"version": "3.0.0",
"version": "3.1.0",
"description": "Protocol Buffers for Node.js",

@@ -5,0 +5,0 @@ "repository": {

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