cbor-x 1.6.0 → 1.6.4
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 +26 -7
- package/dist/decode-no-eval.cjs +26 -7
- package/dist/decode-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.cjs +37 -10
- 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 +37 -10
- 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 +37 -10
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +67 -11
- package/dist/test.js.map +1 -1
- package/encode.js +11 -3
- package/package.json +2 -2
package/encode.js
CHANGED
|
@@ -31,8 +31,8 @@ export class Encoder extends Decoder {
|
|
|
31
31
|
let structures
|
|
32
32
|
let referenceMap
|
|
33
33
|
options = options || {}
|
|
34
|
-
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position
|
|
35
|
-
return target.utf8Write(string, position,
|
|
34
|
+
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
|
|
35
|
+
return target.utf8Write(string, position, target.byteLength - position)
|
|
36
36
|
} : (textEncoder && textEncoder.encodeInto) ?
|
|
37
37
|
function(string, position) {
|
|
38
38
|
return textEncoder.encodeInto(string, target.subarray(position)).written
|
|
@@ -413,7 +413,7 @@ export class Encoder extends Decoder {
|
|
|
413
413
|
targetView.setUint32(position, value)
|
|
414
414
|
position += 4
|
|
415
415
|
}
|
|
416
|
-
} else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer
|
|
416
|
+
} else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer, 31-bit or less
|
|
417
417
|
if (value >= -0x18) {
|
|
418
418
|
target[position++] = 0x1f - value
|
|
419
419
|
} else if (value >= -0x100) {
|
|
@@ -428,6 +428,11 @@ export class Encoder extends Decoder {
|
|
|
428
428
|
targetView.setUint32(position, ~value)
|
|
429
429
|
position += 4
|
|
430
430
|
}
|
|
431
|
+
} else if (!this.alwaysUseFloat && value < 0 && value >= -0x100000000 && Math.floor(value) === value) {
|
|
432
|
+
// negative integer, 32-bit or less
|
|
433
|
+
target[position++] = 0x3a
|
|
434
|
+
targetView.setUint32(position, -1 - value)
|
|
435
|
+
position += 4
|
|
431
436
|
} else {
|
|
432
437
|
let useFloat32
|
|
433
438
|
if ((useFloat32 = this.useFloat32) > 0 && value < 0x100000000 && value >= -0x80000000) {
|
|
@@ -469,6 +474,9 @@ export class Encoder extends Decoder {
|
|
|
469
474
|
}
|
|
470
475
|
let constructor = value.constructor
|
|
471
476
|
if (constructor === Object) {
|
|
477
|
+
if (this.skipFunction === true) {
|
|
478
|
+
value = Object.fromEntries([...Object.keys(value).filter(x => typeof value[x] !== "function").map(x => [x, value[x]])]);
|
|
479
|
+
}
|
|
472
480
|
writeObject(value)
|
|
473
481
|
} else if (constructor === Array) {
|
|
474
482
|
length = value.length
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbor-x",
|
|
3
3
|
"author": "Kris Zyp",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.4",
|
|
5
5
|
"description": "Ultra-fast and conformant CBOR (RFC 8949) implementation with support for numerous tag extensions including records and structured cloning",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"types": "./index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"node:buffer": false
|
|
76
76
|
},
|
|
77
77
|
"optionalDependencies": {
|
|
78
|
-
"cbor-extract": "^2.2.
|
|
78
|
+
"cbor-extract": "^2.2.2"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@rollup/plugin-json": "^5.0.1",
|