msgpackr 1.8.2 → 1.8.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 +2 -2
- package/dist/index-no-eval.cjs +1 -1
- 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 +1 -1
- 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 +3 -2
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +30 -2
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +2 -1
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/pack.js +1 -1
- package/package.json +2 -2
- package/unpack.js +2 -1
package/dist/test.js
CHANGED
|
@@ -553,7 +553,8 @@
|
|
|
553
553
|
if (string == null) {
|
|
554
554
|
if (bundledStrings$1)
|
|
555
555
|
return readStringJS(length)
|
|
556
|
-
let
|
|
556
|
+
let byteOffset = src.byteOffset;
|
|
557
|
+
let extraction = extractStrings(position$1 - headerLength + byteOffset, srcEnd + byteOffset, src.buffer);
|
|
557
558
|
if (typeof extraction == 'string') {
|
|
558
559
|
string = extraction;
|
|
559
560
|
strings = EMPTY_ARRAY;
|
|
@@ -1139,7 +1140,7 @@
|
|
|
1139
1140
|
let safeEnd;
|
|
1140
1141
|
let bundledStrings = null;
|
|
1141
1142
|
let writeStructSlots;
|
|
1142
|
-
const MAX_BUNDLE_SIZE =
|
|
1143
|
+
const MAX_BUNDLE_SIZE = 0x5500; // maximum characters such that the encoded bytes fits in 16 bits.
|
|
1143
1144
|
const hasNonLatin = /[\u0080-\uFFFF]/;
|
|
1144
1145
|
const RECORD_SYMBOL = Symbol('record-id');
|
|
1145
1146
|
let Packr$1 = class Packr extends Unpackr$1 {
|
|
@@ -3128,6 +3129,29 @@
|
|
|
3128
3129
|
var deserialized = packr.unpack(serialized);
|
|
3129
3130
|
assert.deepEqual(deserialized, data);
|
|
3130
3131
|
});
|
|
3132
|
+
test('pack/unpack large amount of chinese characters', function() {
|
|
3133
|
+
const MSGPACK_OPTIONS = {bundleStrings: true};
|
|
3134
|
+
|
|
3135
|
+
const item = {
|
|
3136
|
+
message: '你好你好你好你好你好你好你好你好你好', // some Chinese characters
|
|
3137
|
+
};
|
|
3138
|
+
|
|
3139
|
+
testSize(100);
|
|
3140
|
+
testSize(1000);
|
|
3141
|
+
testSize(10000);
|
|
3142
|
+
function testSize(size) {
|
|
3143
|
+
const list = [];
|
|
3144
|
+
for (let i = 0; i < size; i++) {
|
|
3145
|
+
list.push({...item});
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
const packer = new Packr(MSGPACK_OPTIONS);
|
|
3149
|
+
const unpacker = new Unpackr(MSGPACK_OPTIONS);
|
|
3150
|
+
const encoded = packer.pack(list);
|
|
3151
|
+
const decoded = unpacker.unpack(encoded);
|
|
3152
|
+
assert.deepEqual(list, decoded);
|
|
3153
|
+
}
|
|
3154
|
+
});
|
|
3131
3155
|
test('pack/unpack sequential data', function () {
|
|
3132
3156
|
var data = {foo: 1, bar: 2};
|
|
3133
3157
|
let packr = new Packr({sequential: true});
|
|
@@ -3793,6 +3817,10 @@
|
|
|
3793
3817
|
var deserialized = packr.unpack(serialized);
|
|
3794
3818
|
assert.deepEqual(deserialized.a, '325283295382932843');
|
|
3795
3819
|
});
|
|
3820
|
+
test('fixint should be one byte', function(){
|
|
3821
|
+
let encoded = pack(123);
|
|
3822
|
+
assert.equal(encoded.length, 1);
|
|
3823
|
+
});
|
|
3796
3824
|
test('numbers', function(){
|
|
3797
3825
|
var data = {
|
|
3798
3826
|
bigEncodable: 48978578104322,
|