cbor-x 1.6.0 → 1.6.3
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 +8 -7
- package/decode.js +2 -2
- package/dist/decode-no-eval.cjs +2 -2
- package/dist/decode-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.cjs +13 -5
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +13 -5
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +37 -6
- package/dist/test.js.map +1 -1
- package/encode.js +11 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -264,6 +264,7 @@
|
|
|
264
264
|
}
|
|
265
265
|
token = dataView.getUint32(position$1);
|
|
266
266
|
position$1 += 4;
|
|
267
|
+
if (majorType === 1) return -1 - token; // can't safely use negation operator here
|
|
267
268
|
break
|
|
268
269
|
case 0x1b:
|
|
269
270
|
if (majorType == 7) {
|
|
@@ -278,8 +279,7 @@
|
|
|
278
279
|
} else if (currentDecoder.int64AsNumber) {
|
|
279
280
|
token = dataView.getUint32(position$1) * 0x100000000;
|
|
280
281
|
token += dataView.getUint32(position$1 + 4);
|
|
281
|
-
} else
|
|
282
|
-
token = dataView.getBigUint64(position$1);
|
|
282
|
+
} else token = dataView.getBigUint64(position$1);
|
|
283
283
|
position$1 += 8;
|
|
284
284
|
break
|
|
285
285
|
case 0x1f:
|
|
@@ -1205,8 +1205,8 @@
|
|
|
1205
1205
|
let structures;
|
|
1206
1206
|
let referenceMap;
|
|
1207
1207
|
options = options || {};
|
|
1208
|
-
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position
|
|
1209
|
-
return target.utf8Write(string, position,
|
|
1208
|
+
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
|
|
1209
|
+
return target.utf8Write(string, position, target.byteLength - position)
|
|
1210
1210
|
} : (textEncoder && textEncoder.encodeInto) ?
|
|
1211
1211
|
function(string, position) {
|
|
1212
1212
|
return textEncoder.encodeInto(string, target.subarray(position)).written
|
|
@@ -1587,7 +1587,7 @@
|
|
|
1587
1587
|
targetView.setUint32(position, value);
|
|
1588
1588
|
position += 4;
|
|
1589
1589
|
}
|
|
1590
|
-
} else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer
|
|
1590
|
+
} else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer, 31-bit or less
|
|
1591
1591
|
if (value >= -0x18) {
|
|
1592
1592
|
target[position++] = 0x1f - value;
|
|
1593
1593
|
} else if (value >= -0x100) {
|
|
@@ -1602,6 +1602,11 @@
|
|
|
1602
1602
|
targetView.setUint32(position, ~value);
|
|
1603
1603
|
position += 4;
|
|
1604
1604
|
}
|
|
1605
|
+
} else if (!this.alwaysUseFloat && value < 0 && value >= -0x100000000 && Math.floor(value) === value) {
|
|
1606
|
+
// negative integer, 32-bit or less
|
|
1607
|
+
target[position++] = 0x3a;
|
|
1608
|
+
targetView.setUint32(position, -1 - value);
|
|
1609
|
+
position += 4;
|
|
1605
1610
|
} else {
|
|
1606
1611
|
let useFloat32;
|
|
1607
1612
|
if ((useFloat32 = this.useFloat32) > 0 && value < 0x100000000 && value >= -0x80000000) {
|
|
@@ -1643,6 +1648,9 @@
|
|
|
1643
1648
|
}
|
|
1644
1649
|
let constructor = value.constructor;
|
|
1645
1650
|
if (constructor === Object) {
|
|
1651
|
+
if (this.skipFunction === true) {
|
|
1652
|
+
value = Object.fromEntries([...Object.keys(value).filter(x => typeof value[x] !== "function").map(x => [x, value[x]])]);
|
|
1653
|
+
}
|
|
1646
1654
|
writeObject(value);
|
|
1647
1655
|
} else if (constructor === Array) {
|
|
1648
1656
|
length = value.length;
|