@gmod/binary-parser
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -26,3 +26,5 @@ "use strict";function _typeof(obj) {if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {_typeof = function _typeof(obj) {return typeof obj;};} else {_typeof = function _typeof(obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};}return _typeof(obj);} //= ======================================================================================= | ||
DoubleLE: 8, | ||
DoubleBE: 8 }; | ||
DoubleBE: 8, | ||
UInt64: 8, | ||
Int64: 8 }; | ||
@@ -463,7 +465,21 @@ | ||
Parser.prototype["generate".concat(type)] = function (ctx) { | ||
ctx.pushCode( | ||
"{0} = buffer.read{1}(offset);", | ||
ctx.generateVariable(this.varName), | ||
type); | ||
if (type === 'UInt64') { | ||
ctx.pushCode( | ||
"{0} = Long.fromBytes(buffer.slice(offset,offset+8), true, this.endian === 'le').toNumber();", | ||
ctx.generateVariable(this.varName), | ||
type); | ||
} else if (type === 'Int64') { | ||
ctx.pushCode( | ||
"{0} = Long.fromBytes(buffer.slice(offset,offset+8), false, this.endian === 'le').toNumber();", | ||
ctx.generateVariable(this.varName), | ||
type); | ||
} else { | ||
ctx.pushCode( | ||
"{0} = buffer.read{1}(offset);", | ||
ctx.generateVariable(this.varName), | ||
type); | ||
} | ||
ctx.pushCode("offset += {0};", PRIMITIVE_TYPES[type]); | ||
@@ -753,5 +769,9 @@ }; | ||
// /////////////////// CRAM-specific types ////////////////////////// | ||
// | ||
Parser.prototype.itf8 = function (varName, options) { | ||
return this.setNextParser("itf8", varName, options); | ||
}; | ||
Parser.prototype.itf8 = function (varName, options) { | ||
return this.setNextParser("itf8", varName, options); | ||
}; | ||
@@ -758,0 +778,0 @@ Parser.prototype.generateItf8 = function (ctx) { |
@@ -26,3 +26,5 @@ //= ======================================================================================= | ||
DoubleLE: 8, | ||
DoubleBE: 8 | ||
DoubleBE: 8, | ||
UInt64: 8, | ||
Int64: 8 | ||
}; | ||
@@ -463,7 +465,21 @@ | ||
Parser.prototype[`generate${type}`] = function(ctx) { | ||
ctx.pushCode( | ||
"{0} = buffer.read{1}(offset);", | ||
ctx.generateVariable(this.varName), | ||
type | ||
); | ||
if (type === "UInt64") { | ||
ctx.pushCode( | ||
"{0} = Long.fromBytes(buffer.slice(offset,offset+8), true, this.endian === 'le').toNumber();", | ||
ctx.generateVariable(this.varName), | ||
type | ||
); | ||
} else if (type === "Int64") { | ||
ctx.pushCode( | ||
"{0} = Long.fromBytes(buffer.slice(offset,offset+8), false, this.endian === 'le').toNumber();", | ||
ctx.generateVariable(this.varName), | ||
type | ||
); | ||
} else { | ||
ctx.pushCode( | ||
"{0} = buffer.read{1}(offset);", | ||
ctx.generateVariable(this.varName), | ||
type | ||
); | ||
} | ||
ctx.pushCode("offset += {0};", PRIMITIVE_TYPES[type]); | ||
@@ -753,5 +769,9 @@ }; | ||
// /////////////////// CRAM-specific types ////////////////////////// | ||
// | ||
Parser.prototype.itf8 = function(varName, options) { | ||
return this.setNextParser("itf8", varName, options); | ||
}; | ||
Parser.prototype.itf8 = function(varName, options) { | ||
return this.setNextParser("itf8", varName, options); | ||
}; | ||
@@ -758,0 +778,0 @@ Parser.prototype.generateItf8 = function(ctx) { |
{ | ||
"name": "@gmod/binary-parser", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "Blazing-fast binary parser builder", | ||
@@ -5,0 +5,0 @@ "main": "dist/binary_parser.js", |
@@ -23,3 +23,7 @@ | ||
.buffer('mylong64bitint', { length: 8, formatter: function(buf) { return Long.fromBytes(buf, true, this.endian==='le').toNumber() } }) | ||
.uint64('mylong64bitint') | ||
.int64('mylong64bitint') | ||
64 bit infers from the endianess of the .endianess, doesn't use uint64le/be | ||
Verification of whether it is valid 2^53 max int is not done for 64 bit either |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63704
1657
29