🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bindata

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bindata - npm Package Compare versions

Comparing version

to
0.0.2

src/types/pascalstring.coffee

232

lib/bindata.js

@@ -290,3 +290,3 @@ (function() {

*/
var BinData, DataType, File, Log, fs,
var BinData, DataType, File, Log, PascalString, fs,
__hasProp = Object.prototype.hasOwnProperty,

@@ -430,6 +430,39 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

Record.prototype.data = {};
Record.prototype._data = {};
function Record(file) {
Record.registerType = function(funcNames, cb) {
var funcName, _i, _len, _results;
if (!(typeof funcNames === "object" && (funcNames.length != null))) {
funcNames = [funcNames];
}
_results = [];
for (_i = 0, _len = funcNames.length; _i < _len; _i++) {
funcName = funcNames[_i];
_results.push(Record.prototype[funcName] = cb);
}
return _results;
};
Record.registerRecord = function(funcNames, record, cb) {
var funcName, _i, _len, _results;
if (!(typeof funcNames === "object" && (funcNames.length != null))) {
funcNames = [funcNames];
}
_results = [];
for (_i = 0, _len = funcNames.length; _i < _len; _i++) {
funcName = funcNames[_i];
_results.push(Record.prototype[funcName] = function(name) {
var r;
r = new record(this.file, this.endian);
r.read();
return this.setData(name, cb(r));
});
}
return _results;
};
function Record(file, endian) {
this.file = file;
if (endian == null) endian = null;
if (endian != null) this.endian = endian;
}

@@ -448,13 +481,13 @@

Record.prototype.toJSON = function() {
return this.data;
return this._data;
};
Record.prototype.setData = function(name, data) {
this.data[name] = data;
this._data[name] = data;
return Object.defineProperty(this, name, {
get: function() {
return this.data[name];
return this._data[name];
},
set: function(value) {
return this.data[name] = value;
return this._data[name] = value;
}

@@ -471,3 +504,3 @@ });

item = new BinData.Type[type](opts);
item.read(this.file.read(item.numBytes()));
item.read(this.file.read(item.numBytes(this._data)));
return this.setData(name, item.snapshot());

@@ -480,85 +513,2 @@ };

Record.prototype.char = function(name) {
return this.readType("Char", name);
};
Record.prototype.uchar = function(name) {
return this.readType("Char", name, {
unsigned: true
});
};
Record.prototype.bool = function(name) {
return this.readType("Bool", name);
};
Record.prototype.short = function(name) {
return this.readType("Short", name);
};
Record.prototype.ushort = function(name) {
return this.readType("Short", name, {
unsigned: true
});
};
Record.prototype.int = function(name) {
return this.readType("Int", name);
};
Record.prototype.uint = function(name) {
return this.readType("Int", name, {
unsigned: true
});
};
Record.prototype.long = function(name) {
return this.readType("Long", name);
};
Record.prototype.ulong = function(name) {
return this.readType("Long", name, {
unsigned: true
});
};
Record.prototype.longlong = function(name) {
return this.readType("LongLong", name);
};
Record.prototype.ulonglong = function(name) {
return this.readType("LongLong", name, {
unsigned: true
});
};
Record.prototype.float = function(name) {
return this.readType("Float", name);
};
Record.prototype.double = function(name) {
return this.readType("Double", name);
};
Record.prototype.string = function(name, opts) {
if (opts == null) opts = {};
return this.readType("String", name, opts);
};
Record.prototype.stringz = function(name, opts) {
if (opts == null) opts = {};
};
Record.prototype.int8 = Record.prototype.char;
Record.prototype.uint8 = Record.prototype.uchar;
Record.prototype.int16 = Record.prototype.short;
Record.prototype.uint16 = Record.prototype.ushort;
Record.prototype.int32 = Record.prototype.int;
Record.prototype.uint32 = Record.prototype.uint;
return Record;

@@ -655,2 +605,6 @@

BinData.Record.registerType("bool", function(name) {
return this.readType("Bool", name);
});
BinData.Type.Char = (function(_super) {

@@ -664,3 +618,3 @@

Char.opts = {
Char.prototype.opts = {
unsigned: false

@@ -690,2 +644,12 @@ };

BinData.Record.registerType(["char", "int8"], function(name) {
return this.readType("Bool", name);
});
BinData.Record.registerType(["uchar", "uint8"], function(name) {
return this.readType("Bool", name, {
unsigned: true
});
});
BinData.Type.Double = (function(_super) {

@@ -711,2 +675,6 @@

BinData.Record.registerType("double", function(name) {
return this.readType("Double", name);
});
BinData.Type.Float = (function(_super) {

@@ -732,2 +700,6 @@

BinData.Record.registerType("float", function(name) {
return this.readType("Float", name);
});
BinData.Type.Int = (function(_super) {

@@ -741,3 +713,3 @@

Int.opts = {
Int.prototype.opts = {
unsigned: false

@@ -767,2 +739,12 @@ };

BinData.Record.registerType(["int", "int32"], function(name) {
return this.readType("Int", name);
});
BinData.Record.registerType(["uint", "uint32"], function(name) {
return this.readType("Int", name, {
unsigned: true
});
});
BinData.Type.Long = (function(_super) {

@@ -776,3 +758,3 @@

Long.opts = {
Long.prototype.opts = {
unsigned: false

@@ -802,2 +784,12 @@ };

BinData.Record.registerType("long", function(name) {
return this.readType("Long", name);
});
BinData.Record.registerType("ulong", function(name) {
return this.readType("Long", name, {
unsigned: true
});
});
BinData.Type.LongLong = (function(_super) {

@@ -811,3 +803,3 @@

LongLong.opts = {
LongLong.prototype.opts = {
unsigned: false

@@ -837,2 +829,35 @@ };

BinData.Record.registerType("longlong", function(name) {
return this.readType("LongLong", name);
});
BinData.Record.registerType("ulonglong", function(name) {
return this.readType("LongLong", name, {
unsigned: true
});
});
PascalString = (function(_super) {
__extends(PascalString, _super);
function PascalString() {
PascalString.__super__.constructor.apply(this, arguments);
}
PascalString.prototype.define = function() {
this.uint8("length");
return this.string("str", {
length: this.length
});
};
return PascalString;
})(BinData.Record);
BinData.Record.registerRecord("pascalString", PascalString, function(record) {
return record.str;
});
BinData.Type.Short = (function(_super) {

@@ -846,3 +871,3 @@

Short.opts = {
Short.prototype.opts = {
unsigned: false

@@ -872,2 +897,10 @@ };

BinData.Record.registerType(["short", "int16"], function(name) {
return this.readType("Short", name);
});
BinData.Record.registerType(["ushort", "uint16"], function(name) {
return this.readType("Short", name);
});
BinData.Type.String = (function(_super) {

@@ -881,3 +914,3 @@

String.opts = {
String.prototype.opts = {
length: 4

@@ -900,2 +933,7 @@ };

BinData.Record.registerType("string", function(name, opts) {
if (opts == null) opts = {};
return this.readType("String", name, opts);
});
}).call(this);
{
"name": "bindata",
"version": "0.0.1",
"version": "0.0.2",
"description": "A structured and understandable way to read/write binary data in Javascript. Inspired by Ruby BinData.",

@@ -21,2 +21,2 @@ "keywords": ["bindata", "binary", "file", "read", "write", "parse"],

}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet