bireader 1.0.28 → 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +15 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +15 -15
- package/package.json +1 -2
- package/src/index.ts +15 -15
package/lib/cjs/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function checkSize(_this, write_bytes, write_bit, offset) {
|
|
|
54
54
|
exports.checkSize = checkSize;
|
|
55
55
|
function skip(_this, bytes, bits) {
|
|
56
56
|
const new_size = (((bytes || 0) + _this.offset) + Math.ceil((_this.bitoffset + (bits || 0)) / 8));
|
|
57
|
-
|
|
57
|
+
check_size(_this, bytes || 0, bits || 0);
|
|
58
58
|
if (new_size > _this.size) {
|
|
59
59
|
if (_this.strict == false) {
|
|
60
60
|
_this.extendArray(new_size - _this.size);
|
|
@@ -763,7 +763,7 @@ function rbit(_this, bits, unsigned, endian) {
|
|
|
763
763
|
}
|
|
764
764
|
exports.rbit = rbit;
|
|
765
765
|
function wbyte(_this, value, unsigned) {
|
|
766
|
-
|
|
766
|
+
check_size(_this, 1, 0);
|
|
767
767
|
if (unsigned == true) {
|
|
768
768
|
if (value < 0 || value > 255) {
|
|
769
769
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
@@ -784,7 +784,7 @@ function wbyte(_this, value, unsigned) {
|
|
|
784
784
|
}
|
|
785
785
|
exports.wbyte = wbyte;
|
|
786
786
|
function rbyte(_this, unsigned) {
|
|
787
|
-
|
|
787
|
+
check_size(_this, 1);
|
|
788
788
|
var read = _this.data[_this.offset];
|
|
789
789
|
_this.offset += 1;
|
|
790
790
|
_this.bitoffset = 0;
|
|
@@ -797,7 +797,7 @@ function rbyte(_this, unsigned) {
|
|
|
797
797
|
}
|
|
798
798
|
exports.rbyte = rbyte;
|
|
799
799
|
function wint16(_this, value, unsigned, endian) {
|
|
800
|
-
|
|
800
|
+
check_size(_this, 2, 0);
|
|
801
801
|
if (unsigned == true) {
|
|
802
802
|
if (value < 0 || value > 65535) {
|
|
803
803
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
@@ -825,7 +825,7 @@ function wint16(_this, value, unsigned, endian) {
|
|
|
825
825
|
}
|
|
826
826
|
exports.wint16 = wint16;
|
|
827
827
|
function rint16(_this, unsigned, endian) {
|
|
828
|
-
|
|
828
|
+
check_size(_this, 2);
|
|
829
829
|
var read;
|
|
830
830
|
if ((endian != undefined ? endian : _this.endian) == "little") {
|
|
831
831
|
read = (_this.data[_this.offset + 1] << 8) | _this.data[_this.offset];
|
|
@@ -874,7 +874,7 @@ function rhalffloat(_this, endian) {
|
|
|
874
874
|
}
|
|
875
875
|
exports.rhalffloat = rhalffloat;
|
|
876
876
|
function whalffloat(_this, value, endian) {
|
|
877
|
-
|
|
877
|
+
check_size(_this, 2, 0);
|
|
878
878
|
const maxValue = 65504;
|
|
879
879
|
const minValue = 5.96e-08;
|
|
880
880
|
if (value < minValue || value > maxValue) {
|
|
@@ -918,7 +918,7 @@ function whalffloat(_this, value, endian) {
|
|
|
918
918
|
}
|
|
919
919
|
exports.whalffloat = whalffloat;
|
|
920
920
|
function wint32(_this, value, unsigned, endian) {
|
|
921
|
-
|
|
921
|
+
check_size(_this, 4, 0);
|
|
922
922
|
if (unsigned == true) {
|
|
923
923
|
if (value < 0 || value > 4294967295) {
|
|
924
924
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
@@ -950,7 +950,7 @@ function wint32(_this, value, unsigned, endian) {
|
|
|
950
950
|
}
|
|
951
951
|
exports.wint32 = wint32;
|
|
952
952
|
function rint32(_this, unsigned, endian) {
|
|
953
|
-
|
|
953
|
+
check_size(_this, 4);
|
|
954
954
|
var read;
|
|
955
955
|
if ((endian != undefined ? endian : _this.endian) == "little") {
|
|
956
956
|
read = ((_this.data[_this.offset + 3] << 24) | (_this.data[_this.offset + 2] << 16) | (_this.data[_this.offset + 1] << 8) | _this.data[_this.offset]);
|
|
@@ -993,7 +993,7 @@ function rfloat(_this, endian) {
|
|
|
993
993
|
}
|
|
994
994
|
exports.rfloat = rfloat;
|
|
995
995
|
function wfloat(_this, value, endian) {
|
|
996
|
-
|
|
996
|
+
check_size(_this, 4, 0);
|
|
997
997
|
const maxValue = 3.402823466e+38;
|
|
998
998
|
const minValue = 1.175494351e-38;
|
|
999
999
|
if (value < minValue || value > maxValue) {
|
|
@@ -1016,7 +1016,7 @@ function wfloat(_this, value, endian) {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
exports.wfloat = wfloat;
|
|
1018
1018
|
function rint64(_this, unsigned, endian) {
|
|
1019
|
-
|
|
1019
|
+
check_size(_this, 8);
|
|
1020
1020
|
// Convert the byte array to a BigInt
|
|
1021
1021
|
let value = BigInt(0);
|
|
1022
1022
|
if ((endian == undefined ? _this.endian : endian) == "little") {
|
|
@@ -1047,7 +1047,7 @@ function rint64(_this, unsigned, endian) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
exports.rint64 = rint64;
|
|
1049
1049
|
function wint64(_this, value, unsigned, endian) {
|
|
1050
|
-
|
|
1050
|
+
check_size(_this, 8, 0);
|
|
1051
1051
|
if (unsigned == true) {
|
|
1052
1052
|
if (value < 0 || value > Math.pow(2, 64) - 1) {
|
|
1053
1053
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
@@ -1102,7 +1102,7 @@ function wint64(_this, value, unsigned, endian) {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
exports.wint64 = wint64;
|
|
1104
1104
|
function wdfloat(_this, value, endian) {
|
|
1105
|
-
|
|
1105
|
+
check_size(_this, 8, 0);
|
|
1106
1106
|
const maxValue = 1.7976931348623158e308;
|
|
1107
1107
|
const minValue = 2.2250738585072014e-308;
|
|
1108
1108
|
if (value < minValue || value > maxValue) {
|
|
@@ -1165,7 +1165,7 @@ function rstring(_this, options) {
|
|
|
1165
1165
|
var endian = options && options.endian || _this.endian;
|
|
1166
1166
|
var terminate = terminateValue;
|
|
1167
1167
|
if (length != undefined) {
|
|
1168
|
-
|
|
1168
|
+
check_size(_this, length);
|
|
1169
1169
|
}
|
|
1170
1170
|
if (typeof terminateValue == "number") {
|
|
1171
1171
|
terminate = terminateValue & 0xFF;
|
|
@@ -1304,7 +1304,7 @@ function wstring(_this, string, options) {
|
|
|
1304
1304
|
if (stringType == 'utf-16') {
|
|
1305
1305
|
totalLength = (length || (encodedString.length * 2)) + (terminateValue != undefined ? 2 : 0);
|
|
1306
1306
|
}
|
|
1307
|
-
|
|
1307
|
+
check_size(_this, totalLength, 0);
|
|
1308
1308
|
// Write the string bytes to the Uint8Array
|
|
1309
1309
|
for (let i = 0; i < encodedString.length; i++) {
|
|
1310
1310
|
if (stringType === 'utf-16') {
|
|
@@ -1370,7 +1370,7 @@ function wstring(_this, string, options) {
|
|
|
1370
1370
|
if (stringType == 'wide-pascal') {
|
|
1371
1371
|
totalLength = (length || (encodedString.length * 2)) + lengthWriteSize;
|
|
1372
1372
|
}
|
|
1373
|
-
|
|
1373
|
+
check_size(_this, totalLength, 0);
|
|
1374
1374
|
if (lengthWriteSize == 1) {
|
|
1375
1375
|
_this.writeUByte(maxBytes);
|
|
1376
1376
|
}
|