bireader 1.0.56 → 1.0.59
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/README.md +2 -2
- package/lib/cjs/index.cjs +19 -11
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/index.d.cts.map +1 -1
- package/lib/esm/index.d.mts.map +1 -1
- package/lib/esm/index.mjs +19 -11
- package/lib/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -1222,11 +1222,15 @@ function rfloat(_this, endian) {
|
|
|
1222
1222
|
}
|
|
1223
1223
|
function wfloat(_this, value, endian) {
|
|
1224
1224
|
check_size(_this, 4, 0);
|
|
1225
|
-
const
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1225
|
+
const MIN_POSITIVE_FLOAT32 = Number.MIN_VALUE;
|
|
1226
|
+
const MAX_POSITIVE_FLOAT32 = 3.4028235e+38;
|
|
1227
|
+
const MIN_NEGATIVE_FLOAT32 = -3.4028235e+38;
|
|
1228
|
+
const MAX_NEGATIVE_FLOAT32 = -Number.MIN_VALUE;
|
|
1229
|
+
if (!((value === 0) ||
|
|
1230
|
+
(value >= MIN_POSITIVE_FLOAT32 && value <= MAX_POSITIVE_FLOAT32) ||
|
|
1231
|
+
(value >= MIN_NEGATIVE_FLOAT32 && value <= MAX_NEGATIVE_FLOAT32))) {
|
|
1228
1232
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
1229
|
-
throw new Error('Value is out of range for the specified float length.' + " min: " +
|
|
1233
|
+
throw new Error('Value is out of range for the specified float length.' + " min: " + MIN_NEGATIVE_FLOAT32 + " max: " + MAX_POSITIVE_FLOAT32 + " value: " + value);
|
|
1230
1234
|
}
|
|
1231
1235
|
const dataView = new DataView(new Uint8Array(4).buffer);
|
|
1232
1236
|
dataView.setFloat32(0, value, true);
|
|
@@ -1329,11 +1333,15 @@ function wint64(_this, value, unsigned, endian) {
|
|
|
1329
1333
|
}
|
|
1330
1334
|
function wdfloat(_this, value, endian) {
|
|
1331
1335
|
check_size(_this, 8, 0);
|
|
1332
|
-
const
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1336
|
+
const MIN_POSITIVE_FLOAT64 = 2.2250738585072014e-308;
|
|
1337
|
+
const MAX_POSITIVE_FLOAT64 = Number.MAX_VALUE;
|
|
1338
|
+
const MIN_NEGATIVE_FLOAT64 = -Number.MAX_VALUE;
|
|
1339
|
+
const MAX_NEGATIVE_FLOAT64 = -2.2250738585072014e-308;
|
|
1340
|
+
if (!((value === 0) ||
|
|
1341
|
+
(value >= MIN_POSITIVE_FLOAT64 && value <= MAX_POSITIVE_FLOAT64) ||
|
|
1342
|
+
(value >= MIN_NEGATIVE_FLOAT64 && value <= MAX_NEGATIVE_FLOAT64))) {
|
|
1335
1343
|
_this.errorDump ? "[Error], hexdump:\n" + _this.hexdump() : "";
|
|
1336
|
-
throw new Error('Value is out of range for the specified 64bit length.' + " min: " +
|
|
1344
|
+
throw new Error('Value is out of range for the specified 64bit length.' + " min: " + MIN_NEGATIVE_FLOAT64 + " max: " + MAX_POSITIVE_FLOAT64 + " value: " + value);
|
|
1337
1345
|
}
|
|
1338
1346
|
const intArray = new Int32Array(2);
|
|
1339
1347
|
const floatArray = new Float64Array(intArray.buffer);
|
|
@@ -1589,11 +1597,10 @@ function wstring(_this, string, options) {
|
|
|
1589
1597
|
}
|
|
1590
1598
|
var maxBytes = Math.min(string.length, maxLength);
|
|
1591
1599
|
const encodedString = encoder.encode(string.substring(0, maxBytes));
|
|
1592
|
-
var totalLength = (length || encodedString.length)
|
|
1600
|
+
var totalLength = (length || encodedString.length);
|
|
1593
1601
|
if (stringType == 'wide-pascal') {
|
|
1594
|
-
totalLength = (length || (encodedString.length * 2))
|
|
1602
|
+
totalLength = (length || (encodedString.length * 2));
|
|
1595
1603
|
}
|
|
1596
|
-
check_size(_this, totalLength, 0);
|
|
1597
1604
|
if (lengthWriteSize == 1) {
|
|
1598
1605
|
_this.writeUByte(maxBytes);
|
|
1599
1606
|
}
|
|
@@ -1603,6 +1610,7 @@ function wstring(_this, string, options) {
|
|
|
1603
1610
|
else if (lengthWriteSize == 4) {
|
|
1604
1611
|
_this.writeUInt32(maxBytes, endian);
|
|
1605
1612
|
}
|
|
1613
|
+
check_size(_this, totalLength, 0);
|
|
1606
1614
|
// Write the string bytes to the Uint8Array
|
|
1607
1615
|
for (let i = 0; i < encodedString.length; i++) {
|
|
1608
1616
|
if (stringType == 'wide-pascal') {
|