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.5.1 to 1.6.0

4

doc/history.md
# History
## 1.6.0
* add full packet parser
## 1.5.1

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

2

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

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

@@ -8,4 +8,5 @@ const ProtoDef = require("./protodef");

Parser:require("./serializer").Parser,
FullPacketParser:require("./serializer").FullPacketParser,
types:proto.types,
utils:require("./utils")
};

@@ -62,5 +62,35 @@ const Transform = require("readable-stream").Transform;

class FullPacketParser extends Transform {
constructor(proto,mainType) {
super({ readableObjectMode: true });
this.proto=proto;
this.mainType=mainType;
}
parsePacketBuffer(buffer) {
return this.proto.parsePacketBuffer(this.mainType,buffer);
}
_transform(chunk, enc, cb) {
try {
var packet = this.parsePacketBuffer(chunk);
if(packet.metadata.size!=chunk.length)
cb(new Error("Chunk size is "+chunk.length+" but only "+packet.metadata.size+" was read "+chunk.buffer.toString("hex")));
else {
this.push(packet);
cb();
}
}
catch(e) {
cb(e);
}
}
}
module.exports={
Serializer:Serializer,
Parser:Parser
Parser:Parser,
FullPacketParser:FullPacketParser
};
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