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

struct

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

struct - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

43

index.js

@@ -0,3 +1,10 @@

/**
* Default export `Struct`.
*/
// export default Struct;
module.exports = exports = Struct;
function byteField(p, offset) {
this.length = 1;
this.offset = offset;
this.get = function() {

@@ -13,2 +20,3 @@ return p.buf[offset];

this.length = length;
this.offset = offset;
this.get = function() {

@@ -24,2 +32,3 @@ return (p.buf[offset] > 0 );

this.length = length;
this.offset = offset;

@@ -92,6 +101,10 @@ function bec(cb) {

function charField(p, offset, length, encoding) {
this.length = length;
this.encoding = encoding;
this.get = function() {
var result = p.buf.toString(this.encoding, offset, offset + length);
var self = this;
self.length = length;
self.offset = offset;
self.encoding = encoding;
self.get = function() {
if (!length) return;
var result = p.buf.toString(self.encoding, offset, offset + length);
var strlen = result.indexOf("\0");

@@ -104,7 +117,15 @@ if (strlen == -1) {

}
this.set = function(val) {
self.set = function(val) {
if (!length) return;
/*
// comment off these might be less rubust, but chars encoding
// would be ok
val += "\0";
if (val.length > length)
val = val.substring(0, length);
p.buf.write(val, offset, this.encoding);
*/
// buf.write(string, [offset], [length], [encoding])
p.buf.write(val, offset, length, self.encoding);
}

@@ -115,2 +136,3 @@ }

this.length = struct.length();
this.offset = offset;
this.get = function() {

@@ -140,2 +162,3 @@ return struct;

this.length = as.length();
this.offset = offset;
this.allocate = function() {

@@ -269,3 +292,3 @@ as._setBuff(p.buf.slice(offset, offset + as.length()));

this._setBuff = function(buff) {
this._setBuff = this.setBuffer = function(buff) {
priv.buf = buff;

@@ -289,2 +312,6 @@ applyClosures(priv);

this.getOffset = function(field){
if(priv.fields[field]) return priv.fields[field].offset;
}
this.clone = function() {

@@ -367,3 +394,1 @@ var c = new Struct;

}
exports.Struct = Struct;
{ "name" : "struct"
, "version" : "v0.0.6"
, "version" : "v0.0.7"
, "description" : "Pack/Unpack multibyte binary values from/to buffers "

@@ -4,0 +4,0 @@ , "author": "Denys Khanzhiyev"

@@ -18,3 +18,3 @@ Struct

var Struct = require('../index.js').Struct;
var Struct = require('struct');

@@ -21,0 +21,0 @@ var Person = Struct()

@@ -1,2 +0,2 @@

var Struct = require('../index.js').Struct;
var Struct = require('../index.js');

@@ -40,2 +40,2 @@ var

console.log(t2[0]-t2[1]);
console.log(t3[0]-t3[1]);
console.log(t3[0]-t3[1]);

@@ -1,2 +0,2 @@

var Struct = require('../index.js').Struct;
var Struct = require('../index.js');

@@ -3,0 +3,0 @@ var Person = Struct()

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