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

protodef

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protodef - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

10

doc/api.md

@@ -87,2 +87,12 @@ # API

## CompiledProtodef
The class of which an instance is returned by compileProtoDefSync
It follows the same interface as ProtoDef : read, write, sizeOf, createPacketBuffer, parsePacketBuffer
Its constructor is CompiledProtodef(sizeOfCtx, writeCtx, readCtx).
sizeOfCtx, writeCtx and readCtx are the compiled version of sizeOf, write and read. They are produced by Compiler.compile
It can be used directly for easier debugging/using already compiled js.
## utils

@@ -89,0 +99,0 @@

4

doc/history.md
# History
## 1.10.0
* exposed CompiledProtodef
## 1.9.0

@@ -4,0 +8,0 @@

2

package.json
{
"name": "protodef",
"version": "1.9.0",
"version": "1.10.0",
"description": "A simple yet powerful way to define binary protocols",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -421,3 +421,4 @@ const numeric = require('./datatypes/numeric')

SizeOfCompiler,
ProtoDefCompiler
ProtoDefCompiler,
CompiledProtodef
}

@@ -54,3 +54,3 @@ module.exports = {

}
code += `const { value: ${trueName}, size: ${sizeName} } = ` + compiler.callType(type, offsetExpr) + '\n'
code += `let { value: ${trueName}, size: ${sizeName} } = ` + compiler.callType(type, offsetExpr) + '\n'
offsetExpr += ` + ${sizeName}`

@@ -101,3 +101,3 @@ }

trueName = compiler.getField(name)
code += `const ${trueName} = value.${name}\n`
code += `let ${trueName} = value.${name}\n`
}

@@ -152,3 +152,3 @@ code += 'offset = ' + compiler.callType(trueName, type) + '\n'

trueName = compiler.getField(name)
code += `const ${trueName} = value.${name}\n`
code += `let ${trueName} = value.${name}\n`
}

@@ -155,0 +155,0 @@ code += 'size += ' + compiler.callType(trueName, type) + '\n'

@@ -63,3 +63,3 @@ module.exports = {

let code = 'const { value, size } = ' + compiler.callType(mapper.type) + '\n'
code += 'return { value: ' + JSON.stringify(sanitizeMappings(mapper.mappings)) + '[value], size }'
code += 'return { value: ' + JSON.stringify(sanitizeMappings(mapper.mappings)) + '[value] || value, size }'
return compiler.wrapCode(code)

@@ -122,3 +122,3 @@ }]

const mappings = JSON.stringify(swapMappings(mapper.mappings))
const code = 'return ' + compiler.callType(`${mappings}[value]`, mapper.type)
const code = 'return ' + compiler.callType(`${mappings}[value] || value`, mapper.type)
return compiler.wrapCode(code)

@@ -155,3 +155,3 @@ }]

const mappings = JSON.stringify(swapMappings(mapper.mappings))
const code = 'return ' + compiler.callType(`${mappings}[value]`, mapper.type)
const code = 'return ' + compiler.callType(`${mappings}[value] || value`, mapper.type)
return compiler.wrapCode(code)

@@ -166,4 +166,7 @@ }]

for (let key in json) {
const val = json[key]
let val = json[key]
key = hex2dec(key)
if (!isNaN(val)) val = Number(val)
if (val === 'true') val = true
if (val === 'false') val = false
ret[key] = val

@@ -170,0 +173,0 @@ }

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