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

binarytf

Package Overview
Dependencies
Maintainers
1
Versions
223
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binarytf - npm Package Compare versions

Comparing version

to
2.0.0

12

dist/lib/Deserializer.js

@@ -32,8 +32,8 @@ "use strict";

case constants_1.BinaryTokens.Undefined: return undefined;
case constants_1.BinaryTokens.PByte: return this.read8();
case constants_1.BinaryTokens.NByte: return -this.read8();
case constants_1.BinaryTokens.PInt32: return this.read32();
case constants_1.BinaryTokens.NInt32: return -this.read32();
case constants_1.BinaryTokens.PFloat64: return this.readF64();
case constants_1.BinaryTokens.NFloat64: return -this.readF64();
case constants_1.BinaryTokens.UnsignedByte: return this.read8();
case constants_1.BinaryTokens.SignedByte: return -this.read8();
case constants_1.BinaryTokens.UnsignedInt32: return this.read32();
case constants_1.BinaryTokens.SignedInt32: return -this.read32();
case constants_1.BinaryTokens.UnsignedFloat64: return this.readF64();
case constants_1.BinaryTokens.SignedFloat64: return -this.readF64();
case constants_1.BinaryTokens.Array: return this.readValueArray();

@@ -40,0 +40,0 @@ case constants_1.BinaryTokens.EmptyArray: return this.createObjectID([]);

@@ -8,4 +8,6 @@ "use strict";

// Immutable
const MIN_INT32 = -(2 ** 31);
const MAX_INT32 = (2 ** 31) - 1;
const MIN_INT8 = -127;
const MAX_INT8 = 255;
const MIN_INT32 = -2147483647;
const MAX_INT32 = 4294967295;
// Mutable

@@ -85,18 +87,18 @@ const float64Array = new Float64Array(1);

switch (type) {
case constants_1.BinaryTokens.NByte:
case constants_1.BinaryTokens.SignedByte:
this.write8(-value);
break;
case constants_1.BinaryTokens.PByte:
case constants_1.BinaryTokens.UnsignedByte:
this.write8(value);
break;
case constants_1.BinaryTokens.NInt32:
case constants_1.BinaryTokens.SignedInt32:
this.write32(-value);
break;
case constants_1.BinaryTokens.PInt32:
case constants_1.BinaryTokens.UnsignedInt32:
this.write32(value);
break;
case constants_1.BinaryTokens.NFloat64:
case constants_1.BinaryTokens.SignedFloat64:
this.writeF64(-value);
break;
case constants_1.BinaryTokens.PFloat64:
case constants_1.BinaryTokens.UnsignedFloat64:
this.writeF64(value);

@@ -295,14 +297,14 @@ break;

getNumberType(value) {
const sign = value >= 0 ? 0 : 1;
const sign = value < 0;
if (value % 1 === 0) {
// Byte (N | P)
if (value >= -0xFF && value <= 0xFF)
return sign ? constants_1.BinaryTokens.NByte : constants_1.BinaryTokens.PByte;
// Int32 (N | P)
// Byte (S | U)
if (value >= MIN_INT8 && value <= MAX_INT8)
return sign ? constants_1.BinaryTokens.SignedByte : constants_1.BinaryTokens.UnsignedByte;
// Int32 (S | U)
if (value >= MIN_INT32 && value <= MAX_INT32)
return sign ? constants_1.BinaryTokens.NInt32 : constants_1.BinaryTokens.PInt32;
return sign ? constants_1.BinaryTokens.SignedInt32 : constants_1.BinaryTokens.UnsignedInt32;
// Fallback to float
}
// Float64
return sign ? constants_1.BinaryTokens.NFloat64 : constants_1.BinaryTokens.PFloat64;
return sign ? constants_1.BinaryTokens.SignedFloat64 : constants_1.BinaryTokens.UnsignedFloat64;
}

@@ -309,0 +311,0 @@ ensureAlloc(amount) {

@@ -10,8 +10,8 @@ export declare enum BinaryTokens {

Undefined = 7,
PByte = 8,
NByte = 9,
PInt32 = 10,
NInt32 = 11,
PFloat64 = 12,
NFloat64 = 13,
UnsignedByte = 8,
SignedByte = 9,
UnsignedInt32 = 10,
SignedInt32 = 11,
UnsignedFloat64 = 12,
SignedFloat64 = 13,
Array = 14,

@@ -18,0 +18,0 @@ EmptyArray = 15,

@@ -13,8 +13,8 @@ "use strict";

BinaryTokens[BinaryTokens["Undefined"] = 7] = "Undefined";
BinaryTokens[BinaryTokens["PByte"] = 8] = "PByte";
BinaryTokens[BinaryTokens["NByte"] = 9] = "NByte";
BinaryTokens[BinaryTokens["PInt32"] = 10] = "PInt32";
BinaryTokens[BinaryTokens["NInt32"] = 11] = "NInt32";
BinaryTokens[BinaryTokens["PFloat64"] = 12] = "PFloat64";
BinaryTokens[BinaryTokens["NFloat64"] = 13] = "NFloat64";
BinaryTokens[BinaryTokens["UnsignedByte"] = 8] = "UnsignedByte";
BinaryTokens[BinaryTokens["SignedByte"] = 9] = "SignedByte";
BinaryTokens[BinaryTokens["UnsignedInt32"] = 10] = "UnsignedInt32";
BinaryTokens[BinaryTokens["SignedInt32"] = 11] = "SignedInt32";
BinaryTokens[BinaryTokens["UnsignedFloat64"] = 12] = "UnsignedFloat64";
BinaryTokens[BinaryTokens["SignedFloat64"] = 13] = "SignedFloat64";
BinaryTokens[BinaryTokens["Array"] = 14] = "Array";

@@ -21,0 +21,0 @@ BinaryTokens[BinaryTokens["EmptyArray"] = 15] = "EmptyArray";

{
"name": "binarytf",
"version": "1.0.0",
"version": "2.0.0",
"description": "Binary Term Format",

@@ -15,3 +15,3 @@ "main": "dist/index.js",

"coverage:report": "yarn nyc report --reporter=cobertura",
"build": "tsc.cmd -p .",
"build": "tsc -p .",
"watch": "tsc -p . -w"

@@ -18,0 +18,0 @@ },

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

# binarytf
# binarytf <img src="https://github.com/binarytf/binarytf/blob/master/static/logo.png?raw=true" align="right" width="22%">

@@ -3,0 +3,0 @@ <div align="center">

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