msgpackr 1.8.3 → 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/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 +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +28 -1
- package/dist/test.js.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/dist/test.js
CHANGED
|
@@ -1140,7 +1140,7 @@
|
|
|
1140
1140
|
let safeEnd;
|
|
1141
1141
|
let bundledStrings = null;
|
|
1142
1142
|
let writeStructSlots;
|
|
1143
|
-
const MAX_BUNDLE_SIZE =
|
|
1143
|
+
const MAX_BUNDLE_SIZE = 0x5500; // maximum characters such that the encoded bytes fits in 16 bits.
|
|
1144
1144
|
const hasNonLatin = /[\u0080-\uFFFF]/;
|
|
1145
1145
|
const RECORD_SYMBOL = Symbol('record-id');
|
|
1146
1146
|
let Packr$1 = class Packr extends Unpackr$1 {
|
|
@@ -3129,6 +3129,29 @@
|
|
|
3129
3129
|
var deserialized = packr.unpack(serialized);
|
|
3130
3130
|
assert.deepEqual(deserialized, data);
|
|
3131
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
|
+
});
|
|
3132
3155
|
test('pack/unpack sequential data', function () {
|
|
3133
3156
|
var data = {foo: 1, bar: 2};
|
|
3134
3157
|
let packr = new Packr({sequential: true});
|
|
@@ -3794,6 +3817,10 @@
|
|
|
3794
3817
|
var deserialized = packr.unpack(serialized);
|
|
3795
3818
|
assert.deepEqual(deserialized.a, '325283295382932843');
|
|
3796
3819
|
});
|
|
3820
|
+
test('fixint should be one byte', function(){
|
|
3821
|
+
let encoded = pack(123);
|
|
3822
|
+
assert.equal(encoded.length, 1);
|
|
3823
|
+
});
|
|
3797
3824
|
test('numbers', function(){
|
|
3798
3825
|
var data = {
|
|
3799
3826
|
bigEncodable: 48978578104322,
|