@cloudpss/ubjson 0.4.18 → 0.4.20

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.
@@ -44,7 +44,9 @@ for (const i of [64, 256, 1024, 8192, 16384]) {
44
44
  timeMixed += performance.now() - start;
45
45
  }
46
46
  console.log(
47
- `[${withBuffer ? 'w/ ' : 'w/o'} buffer] ${pb(size)}\t${t(time1 / LOOP)} \t${t(time2 / LOOP)} \t${t(time3 / LOOP)} \t${t(timeMixed / LOOP)}`,
47
+ `[${withBuffer ? 'w/ ' : 'w/o'} buffer] ${pb(size)}\t${t(time1 / LOOP)} \t${t(time2 / LOOP)} \t${t(
48
+ time3 / LOOP,
49
+ )} \t${t(timeMixed / LOOP)}`,
48
50
  );
49
51
  }
50
52
  }
@@ -34,8 +34,8 @@ for (let index = 50; index < 1000; index = Math.trunc(index * 1.2)) {
34
34
  const ratioOptimal = decodeTimeOptimal / decodeTimeSystem;
35
35
  const ratioJs = decodeTimeJs / decodeTimeSystem;
36
36
  console.log(
37
- `Data: ${data.byteLength} \t${t(decodeTimeSystem / LOOP)} ${t(decodeTimeOptimal / LOOP)} ${(ratioOptimal * 100).toFixed(3)}%\t${t(
38
- decodeTimeJs / LOOP,
39
- )} ${(ratioJs * 100).toFixed(3)}%`,
37
+ `Data: ${data.byteLength} \t${t(decodeTimeSystem / LOOP)} ${t(decodeTimeOptimal / LOOP)} ${(
38
+ ratioOptimal * 100
39
+ ).toFixed(3)}%\t${t(decodeTimeJs / LOOP)} ${(ratioJs * 100).toFixed(3)}%`,
40
40
  );
41
41
  }
package/benchmark.js CHANGED
@@ -41,9 +41,9 @@ for (const { file, data, obj } of testData) {
41
41
 
42
42
  console.assert(lodash.isEqual(obj, obj2));
43
43
  console.log(
44
- `File: ${file.padEnd(28)} \tRaw: ${pb(data.length)}\tencode: ${t(encodeTime / LOOP)}\tencode stream: ${t(encodeTime2 / LOOP)}\tdecode: ${t(
45
- decodeTime / LOOP,
46
- )}`,
44
+ `File: ${file.padEnd(28)} \tRaw: ${pb(data.length)}\tencode: ${t(encodeTime / LOOP)}\tencode stream: ${t(
45
+ encodeTime2 / LOOP,
46
+ )}\tdecode: ${t(decodeTime / LOOP)}`,
47
47
  );
48
48
  }
49
49
  console.log('');
@@ -1 +1 @@
1
- {"version":3,"file":"string-decoder.js","sourceRoot":"","sources":["../../src/common/string-decoder.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAEhI,iEAAiE;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,UAAW,CAAC,CAAC,CAAC,GAAG,CAAC;AAE9E,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,SAAS;AACT,MAAM,UAAU,QAAQ,CAAC,KAAiB,EAAE,KAAa,EAAE,GAAW;IAClE,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,OAAO,MAAM,GAAG,GAAG,EAAE;QACjB,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE;YACtB,SAAS;YACT,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrB;aAAM,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;YAChC,UAAU;YACV,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAA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AAE,MAAM,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudpss/ubjson",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -1,5 +1,6 @@
1
1
  /* c8 ignore next 2: TextDecoder always present, fallback tested */
2
- export const textDecoder = typeof TextDecoder == 'function' ? new TextDecoder('utf8', { ignoreBOM: true, fatal: false }) : null;
2
+ export const textDecoder =
3
+ typeof TextDecoder == 'function' ? new TextDecoder('utf8', { ignoreBOM: true, fatal: false }) : null;
3
4
 
4
5
  /* c8 ignore next: TextDecoder always present, fallback tested */
5
6
  export const TEXT_ENCODER_THRESHOLD = textDecoder == null ? 0xffff_ffff : 200;
package/src/encoder.ts CHANGED
@@ -60,7 +60,9 @@ export class Encoder extends EncoderBase {
60
60
  }
61
61
 
62
62
  // 合并缓冲区
63
- const result = new Uint8Array(this.length + this.flushedBuffers.reduce((sum, buffer) => sum + buffer.byteLength, 0));
63
+ const result = new Uint8Array(
64
+ this.length + this.flushedBuffers.reduce((sum, buffer) => sum + buffer.byteLength, 0),
65
+ );
64
66
  let offset = 0;
65
67
  for (const buffer of this.flushedBuffers) {
66
68
  result.set(buffer, offset);
package/tests/decode.js CHANGED
@@ -109,7 +109,9 @@ test('decode huge string', () => {
109
109
  });
110
110
 
111
111
  test('decode huge string [error]', () => {
112
- expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).toThrow(/Unsupported type int64/);
112
+ expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).toThrow(
113
+ /Unsupported type int64/,
114
+ );
113
115
  });
114
116
 
115
117
  test('decode array', () => {
@@ -145,10 +147,9 @@ test('decode array (strongly typed, empty, optimized)', () => {
145
147
  });
146
148
 
147
149
  test('decode N-D array (strongly typed, optimized)', () => {
148
- expect(decode(toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6))).toEqual([
149
- new Int8Array([1, 2, 3]),
150
- new Int8Array([4, 5, 6]),
151
- ]);
150
+ expect(
151
+ decode(toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6)),
152
+ ).toEqual([new Int8Array([1, 2, 3]), new Int8Array([4, 5, 6])]);
152
153
  });
153
154
 
154
155
  test('decode array of objects (optimized)', () => {
@@ -324,7 +325,9 @@ test('decode array (int32, strongly typed, optimized) [use typed array]', () =>
324
325
  });
325
326
 
326
327
  test('decode array (int64, strongly typed, optimized) [use typed array]', () => {
327
- expect(() => decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98))).toThrow();
328
+ expect(() =>
329
+ decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98)),
330
+ ).toThrow();
328
331
  });
329
332
 
330
333
  test('decode array (float32, strongly typed, optimized) [use typed array]', () => {
@@ -334,7 +337,32 @@ test('decode array (float32, strongly typed, optimized) [use typed array]', () =
334
337
  });
335
338
 
336
339
  test('decode array (float64, strongly typed, optimized) [use typed array]', () => {
337
- const actual = decode(toBuffer('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
340
+ const actual = decode(
341
+ toBuffer(
342
+ '[',
343
+ '$',
344
+ 'D',
345
+ '#',
346
+ 'i',
347
+ 2,
348
+ 0x3f,
349
+ 0xd0,
350
+ 0x00,
351
+ 0x00,
352
+ 0x00,
353
+ 0x00,
354
+ 0x00,
355
+ 0x00,
356
+ 0x3f,
357
+ 0xc0,
358
+ 0x00,
359
+ 0x00,
360
+ 0x00,
361
+ 0x00,
362
+ 0x00,
363
+ 0x00,
364
+ ),
365
+ );
338
366
  expect(actual).toBeInstanceOf(Float64Array);
339
367
  expect(actual).toEqual(Float64Array.from([0.25, 0.125]));
340
368
  });
@@ -348,7 +376,11 @@ test('decode object', () => {
348
376
  });
349
377
 
350
378
  test('decode object (with no-op)', () => {
351
- expect(decode(toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'))).toEqual({ a: 1, b: 2, c: 3 });
379
+ expect(
380
+ decode(
381
+ toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'),
382
+ ),
383
+ ).toEqual({ a: 1, b: 2, c: 3 });
352
384
  });
353
385
 
354
386
  test('decode array (empty, optimized)', () => {
package/tests/e2e.js CHANGED
@@ -34,12 +34,30 @@ test('encode/decode complex object', () => {
34
34
  traces: [
35
35
  {
36
36
  name: 'test',
37
- x: new Float64Array([1, 2, 3, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, Number.MAX_VALUE, Number.MIN_VALUE]),
37
+ x: new Float64Array([
38
+ 1,
39
+ 2,
40
+ 3,
41
+ Number.NEGATIVE_INFINITY,
42
+ Number.POSITIVE_INFINITY,
43
+ Number.NaN,
44
+ Number.MAX_VALUE,
45
+ Number.MIN_VALUE,
46
+ ]),
38
47
  y: new Int8Array([0, 4, 5, 6, -128, -1, 127]),
39
48
  },
40
49
  {
41
50
  name: 'test2',
42
- x: new Float32Array([1, 2, 3, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, Number.MAX_VALUE, Number.MIN_VALUE]),
51
+ x: new Float32Array([
52
+ 1,
53
+ 2,
54
+ 3,
55
+ Number.NEGATIVE_INFINITY,
56
+ Number.POSITIVE_INFINITY,
57
+ Number.NaN,
58
+ Number.MAX_VALUE,
59
+ Number.MIN_VALUE,
60
+ ]),
43
61
  y: new Int16Array([4, 5, 6, -32768, 32767]),
44
62
  },
45
63
  {
@@ -219,7 +237,8 @@ test('encode/decode model', () => {
219
237
  name: 'Pin Key',
220
238
  type: 'choice',
221
239
  value: '',
222
- choices: '=mapper(p,index,array) = {key: p.key, name: p.key, description: p.description};\n$$.revision.pins.map(mapper)',
240
+ choices:
241
+ '=mapper(p,index,array) = {key: p.key, name: p.key, description: p.description};\n$$.revision.pins.map(mapper)',
223
242
  condition: 'true',
224
243
  description: '绑定端口',
225
244
  },
@@ -312,12 +331,30 @@ test('encode/decode complex object (no encodeInto)', () => {
312
331
  traces: [
313
332
  {
314
333
  name: 'test',
315
- x: new Float64Array([1, 2, 3, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, Number.MAX_VALUE, Number.MIN_VALUE]),
334
+ x: new Float64Array([
335
+ 1,
336
+ 2,
337
+ 3,
338
+ Number.NEGATIVE_INFINITY,
339
+ Number.POSITIVE_INFINITY,
340
+ Number.NaN,
341
+ Number.MAX_VALUE,
342
+ Number.MIN_VALUE,
343
+ ]),
316
344
  y: new Int8Array([0, 4, 5, 6, -128, -1, 127]),
317
345
  },
318
346
  {
319
347
  name: 'test2',
320
- x: new Float32Array([1, 2, 3, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, Number.MAX_VALUE, Number.MIN_VALUE]),
348
+ x: new Float32Array([
349
+ 1,
350
+ 2,
351
+ 3,
352
+ Number.NEGATIVE_INFINITY,
353
+ Number.POSITIVE_INFINITY,
354
+ Number.NaN,
355
+ Number.MAX_VALUE,
356
+ Number.MIN_VALUE,
357
+ ]),
321
358
  y: new Int16Array([4, 5, 6, -32768, 32767]),
322
359
  },
323
360
  {
package/tests/encode.js CHANGED
@@ -185,7 +185,9 @@ test('encode array (buffer array)', () => {
185
185
  });
186
186
 
187
187
  test('encode array (int16 typed array)', () => {
188
- expect(toArray(encode(Int16Array.from([4660, -292])))).toEqual(toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc));
188
+ expect(toArray(encode(Int16Array.from([4660, -292])))).toEqual(
189
+ toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc),
190
+ );
189
191
  });
190
192
 
191
193
  test('encode array (int32 typed array)', () => {
@@ -195,12 +197,37 @@ test('encode array (int32 typed array)', () => {
195
197
  });
196
198
 
197
199
  test('encode array (float32 typed array)', () => {
198
- expect(toArray(encode(Float32Array.from([0.25, 0.125])))).toEqual(toArray('[', '$', 'd', '#', 'i', 2, 0x3e, 0x80, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00));
200
+ expect(toArray(encode(Float32Array.from([0.25, 0.125])))).toEqual(
201
+ toArray('[', '$', 'd', '#', 'i', 2, 0x3e, 0x80, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00),
202
+ );
199
203
  });
200
204
 
201
205
  test('encode array (float64 typed array)', () => {
202
206
  expect(toArray(encode(Float64Array.from([0.25, 0.125])))).toEqual(
203
- toArray('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
207
+ toArray(
208
+ '[',
209
+ '$',
210
+ 'D',
211
+ '#',
212
+ 'i',
213
+ 2,
214
+ 0x3f,
215
+ 0xd0,
216
+ 0x00,
217
+ 0x00,
218
+ 0x00,
219
+ 0x00,
220
+ 0x00,
221
+ 0x00,
222
+ 0x3f,
223
+ 0xc0,
224
+ 0x00,
225
+ 0x00,
226
+ 0x00,
227
+ 0x00,
228
+ 0x00,
229
+ 0x00,
230
+ ),
204
231
  );
205
232
  });
206
233
 
@@ -225,7 +252,9 @@ test('encode array (int64 typed array)', () => {
225
252
  });
226
253
 
227
254
  test('encode object', () => {
228
- expect(toArray(encode({ a: 1, b: 2, c: 3 }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'));
255
+ expect(toArray(encode({ a: 1, b: 2, c: 3 }))).toEqual(
256
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'),
257
+ );
229
258
  });
230
259
 
231
260
  test('encode object (empty)', () => {
@@ -237,11 +266,15 @@ test('encode object (empty key)', () => {
237
266
  });
238
267
 
239
268
  test('encode object (mixed)', () => {
240
- expect(toArray(encode({ a: 1, b: 'a', c: true }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
269
+ expect(toArray(encode({ a: 1, b: 'a', c: true }))).toEqual(
270
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
271
+ );
241
272
  });
242
273
 
243
274
  test('encode object (only null values)', () => {
244
- expect(toArray(encode({ a: null, b: null, c: null }))).toEqual(toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'));
275
+ expect(toArray(encode({ a: null, b: null, c: null }))).toEqual(
276
+ toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'),
277
+ );
245
278
  });
246
279
 
247
280
  test('encode object (skip prototype)', () => {
@@ -249,7 +282,9 @@ test('encode object (skip prototype)', () => {
249
282
  obj.a = 1;
250
283
  obj.b = 'a';
251
284
  obj.c = true;
252
- expect(toArray(encode(obj))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
285
+ expect(toArray(encode(obj))).toEqual(
286
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
287
+ );
253
288
  });
254
289
 
255
290
  test('encode object (skip symbol)', () => {
@@ -312,7 +347,9 @@ test('encode huge data (~128M)', () => {
312
347
  const obj = [new Uint8Array(128 * 1024 * 1024 - 20)];
313
348
  obj[0][0] = 0x12;
314
349
  obj[0][1] = 0x34;
315
- expect(toArray(encode(obj).slice(0, 12))).toEqual(toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0x12, 0x34));
350
+ expect(toArray(encode(obj).slice(0, 12))).toEqual(
351
+ toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0x12, 0x34),
352
+ );
316
353
  });
317
354
 
318
355
  test('encode huge data (128M)', () => {
@@ -338,6 +375,8 @@ test('encode huge data (256M)', () => {
338
375
  const encoded = encode(obj);
339
376
  expect(encoded.length).toBe(128 * 1024 * 1024 * 2 + 9 * 2 + 2);
340
377
  expect(toArray(encoded.slice(0, 12))).toEqual(toArray('[', '[', '$', 'U', '#', 'l', 0x8, 0, 0, 0, 0x12, 0x34));
341
- expect(toArray(encoded.slice(128 * 1024 * 1024 + 10, 128 * 1024 * 1024 + 10 + 11))).toEqual(toArray('[', '$', 'U', '#', 'l', 0x8, 0, 0, 0, 0x56, 0x78));
378
+ expect(toArray(encoded.slice(128 * 1024 * 1024 + 10, 128 * 1024 * 1024 + 10 + 11))).toEqual(
379
+ toArray('[', '$', 'U', '#', 'l', 0x8, 0, 0, 0, 0x56, 0x78),
380
+ );
342
381
  expect(toArray(encoded.slice(-1))).toEqual(toArray(']'));
343
382
  });
@@ -140,7 +140,9 @@ test('decode huge string', async () => {
140
140
  });
141
141
 
142
142
  test('decode huge string [error]', async () => {
143
- await expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).rejects.toThrow(/Unsupported type int64/);
143
+ await expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).rejects.toThrow(
144
+ /Unsupported type int64/,
145
+ );
144
146
  });
145
147
 
146
148
  test('decode array', async () => {
@@ -176,10 +178,11 @@ test('decode array (strongly typed, empty, optimized)', async () => {
176
178
  });
177
179
 
178
180
  test('decode N-D array (strongly typed, optimized)', async () => {
179
- expect(await decode(toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6))).toEqual([
180
- new Int8Array([1, 2, 3]),
181
- new Int8Array([4, 5, 6]),
182
- ]);
181
+ expect(
182
+ await decode(
183
+ toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6),
184
+ ),
185
+ ).toEqual([new Int8Array([1, 2, 3]), new Int8Array([4, 5, 6])]);
183
186
  });
184
187
 
185
188
  test('decode array of objects (optimized)', async () => {
@@ -355,7 +358,9 @@ test('decode array (int32, strongly typed, optimized) [use typed array]', async
355
358
  });
356
359
 
357
360
  test('decode array (int64, strongly typed, optimized) [use typed array]', async () => {
358
- await expect(() => decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98))).rejects.toThrow();
361
+ await expect(() =>
362
+ decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98)),
363
+ ).rejects.toThrow();
359
364
  });
360
365
 
361
366
  test('decode array (float32, strongly typed, optimized) [use typed array]', async () => {
@@ -366,7 +371,30 @@ test('decode array (float32, strongly typed, optimized) [use typed array]', asyn
366
371
 
367
372
  test('decode array (float64, strongly typed, optimized) [use typed array]', async () => {
368
373
  const actual = await decode(
369
- toBuffer('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
374
+ toBuffer(
375
+ '[',
376
+ '$',
377
+ 'D',
378
+ '#',
379
+ 'i',
380
+ 2,
381
+ 0x3f,
382
+ 0xd0,
383
+ 0x00,
384
+ 0x00,
385
+ 0x00,
386
+ 0x00,
387
+ 0x00,
388
+ 0x00,
389
+ 0x3f,
390
+ 0xc0,
391
+ 0x00,
392
+ 0x00,
393
+ 0x00,
394
+ 0x00,
395
+ 0x00,
396
+ 0x00,
397
+ ),
370
398
  );
371
399
  expect(actual).toBeInstanceOf(Float64Array);
372
400
  expect(actual).toEqual(Float64Array.from([0.25, 0.125]));
@@ -381,7 +409,11 @@ test('decode object', async () => {
381
409
  });
382
410
 
383
411
  test('decode object (with no-op)', async () => {
384
- expect(await decode(toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'))).toEqual({
412
+ expect(
413
+ await decode(
414
+ toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'),
415
+ ),
416
+ ).toEqual({
385
417
  a: 1,
386
418
  b: 2,
387
419
  c: 3,
@@ -393,7 +425,9 @@ test('decode array (empty, optimized)', async () => {
393
425
  });
394
426
 
395
427
  test('decode object (mixed, optimized)', async () => {
396
- expect(await decode(toBuffer('{', '#', 'i', 3, 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T'))).toEqual({
428
+ expect(
429
+ await decode(toBuffer('{', '#', 'i', 3, 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T')),
430
+ ).toEqual({
397
431
  a: 1,
398
432
  b: 'a',
399
433
  c: true,
@@ -76,7 +76,9 @@ test('encode float32 (too large integer)', async () => {
76
76
  });
77
77
 
78
78
  test('encode float64', async () => {
79
- expect(toArray(await encodeAsync(100_000.003_906_25))).toEqual(toArray('D', 0x40, 0xf8, 0x6a, 0x00, 0x10, 0x00, 0x00, 0x00));
79
+ expect(toArray(await encodeAsync(100_000.003_906_25))).toEqual(
80
+ toArray('D', 0x40, 0xf8, 0x6a, 0x00, 0x10, 0x00, 0x00, 0x00),
81
+ );
80
82
  });
81
83
 
82
84
  test('encode char', async () => {
@@ -192,15 +194,21 @@ test('encode array of objects of arrays', async () => {
192
194
  });
193
195
 
194
196
  test('encode array (int8 typed array)', async () => {
195
- expect(toArray(await encodeAsync(Int8Array.from([18, -2])))).toEqual(toArray('[', '$', 'i', '#', 'i', 2, 0x12, 0xfe));
197
+ expect(toArray(await encodeAsync(Int8Array.from([18, -2])))).toEqual(
198
+ toArray('[', '$', 'i', '#', 'i', 2, 0x12, 0xfe),
199
+ );
196
200
  });
197
201
 
198
202
  test('encode array (uint8 typed array)', async () => {
199
- expect(toArray(await encodeAsync(Uint8Array.from([18, 254])))).toEqual(toArray('[', '$', 'U', '#', 'i', 2, 0x12, 0xfe));
203
+ expect(toArray(await encodeAsync(Uint8Array.from([18, 254])))).toEqual(
204
+ toArray('[', '$', 'U', '#', 'i', 2, 0x12, 0xfe),
205
+ );
200
206
  });
201
207
 
202
208
  test('encode array (int16 typed array)', async () => {
203
- expect(toArray(await encodeAsync(Int16Array.from([4660, -292])))).toEqual(toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc));
209
+ expect(toArray(await encodeAsync(Int16Array.from([4660, -292])))).toEqual(
210
+ toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc),
211
+ );
204
212
  });
205
213
 
206
214
  test('encode array (int32 typed array)', async () => {
@@ -217,7 +225,30 @@ test('encode array (float32 typed array)', async () => {
217
225
 
218
226
  test('encode array (float64 typed array)', async () => {
219
227
  expect(toArray(await encodeAsync(Float64Array.from([0.25, 0.125])))).toEqual(
220
- toArray('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
228
+ toArray(
229
+ '[',
230
+ '$',
231
+ 'D',
232
+ '#',
233
+ 'i',
234
+ 2,
235
+ 0x3f,
236
+ 0xd0,
237
+ 0x00,
238
+ 0x00,
239
+ 0x00,
240
+ 0x00,
241
+ 0x00,
242
+ 0x00,
243
+ 0x3f,
244
+ 0xc0,
245
+ 0x00,
246
+ 0x00,
247
+ 0x00,
248
+ 0x00,
249
+ 0x00,
250
+ 0x00,
251
+ ),
221
252
  );
222
253
  });
223
254
 
@@ -242,7 +273,9 @@ test('encode array (int64 typed array)', async () => {
242
273
  });
243
274
 
244
275
  test('encode object', async () => {
245
- expect(toArray(await encodeAsync({ a: 1, b: 2, c: 3 }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'));
276
+ expect(toArray(await encodeAsync({ a: 1, b: 2, c: 3 }))).toEqual(
277
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'),
278
+ );
246
279
  });
247
280
 
248
281
  test('encode object (empty)', async () => {
@@ -254,11 +287,15 @@ test('encode object (empty key)', async () => {
254
287
  });
255
288
 
256
289
  test('encode object (mixed)', async () => {
257
- expect(toArray(await encodeAsync({ a: 1, b: 'a', c: true }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
290
+ expect(toArray(await encodeAsync({ a: 1, b: 'a', c: true }))).toEqual(
291
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
292
+ );
258
293
  });
259
294
 
260
295
  test('encode object (only null values)', async () => {
261
- expect(toArray(await encodeAsync({ a: null, b: null, c: null }))).toEqual(toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'));
296
+ expect(toArray(await encodeAsync({ a: null, b: null, c: null }))).toEqual(
297
+ toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'),
298
+ );
262
299
  });
263
300
 
264
301
  test('encode object (skip prototype)', async () => {
@@ -266,7 +303,9 @@ test('encode object (skip prototype)', async () => {
266
303
  obj.a = 1;
267
304
  obj.b = 'a';
268
305
  obj.c = true;
269
- expect(toArray(await encodeAsync(obj))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
306
+ expect(toArray(await encodeAsync(obj))).toEqual(
307
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
308
+ );
270
309
  });
271
310
 
272
311
  test('encode object (skip symbol)', async () => {
@@ -312,7 +351,9 @@ test('encode huge typed array (16K)', async () => {
312
351
 
313
352
  test('encode huge typed array (~128M)', async () => {
314
353
  const obj = new Uint8Array(128 * 1024 * 1024 - 10);
315
- expect(toArray((await encodeAsync(obj)).slice(0, 10))).toEqual(toArray('[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xf6, 0));
354
+ expect(toArray((await encodeAsync(obj)).slice(0, 10))).toEqual(
355
+ toArray('[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xf6, 0),
356
+ );
316
357
  });
317
358
 
318
359
  test('encode huge typed array (256M + 1) [error]', async () => {
@@ -327,7 +368,9 @@ test('encode huge typed array (3G) [error]', async () => {
327
368
 
328
369
  test('encode huge data (~128M)', async () => {
329
370
  const obj = [new Uint8Array(128 * 1024 * 1024 - 20)];
330
- expect(toArray((await encodeAsync(obj)).slice(0, 11))).toEqual(toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0));
371
+ expect(toArray((await encodeAsync(obj)).slice(0, 11))).toEqual(
372
+ toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0),
373
+ );
331
374
  });
332
375
 
333
376
  test('encode huge data (256M + 1) [error]', async () => {
@@ -126,7 +126,9 @@ test('decode huge string', async () => {
126
126
  });
127
127
 
128
128
  test('decode huge string [error]', async () => {
129
- await expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).rejects.toThrow(/Unsupported type int64/);
129
+ await expect(() => decode(toBuffer('S', 'L', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'x'))).rejects.toThrow(
130
+ /Unsupported type int64/,
131
+ );
130
132
  });
131
133
 
132
134
  test('decode array', async () => {
@@ -162,10 +164,11 @@ test('decode array (strongly typed, empty, optimized)', async () => {
162
164
  });
163
165
 
164
166
  test('decode N-D array (strongly typed, optimized)', async () => {
165
- expect(await decode(toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6))).toEqual([
166
- new Int8Array([1, 2, 3]),
167
- new Int8Array([4, 5, 6]),
168
- ]);
167
+ expect(
168
+ await decode(
169
+ toBuffer('[', '$', '[', '#', 'i', 2, '$', 'i', '#', 'i', 3, 1, 2, 3, '$', 'i', '#', 'i', 3, 4, 5, 6),
170
+ ),
171
+ ).toEqual([new Int8Array([1, 2, 3]), new Int8Array([4, 5, 6])]);
169
172
  });
170
173
 
171
174
  test('decode array of objects (optimized)', async () => {
@@ -341,7 +344,9 @@ test('decode array (int32, strongly typed, optimized) [use typed array]', async
341
344
  });
342
345
 
343
346
  test('decode array (int64, strongly typed, optimized) [use typed array]', async () => {
344
- await expect(() => decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98))).rejects.toThrow();
347
+ await expect(() =>
348
+ decode(toBuffer('[', '$', 'L', '#', 'i', 1, 0x12, 0x34, 0x56, 0x78, 0xfe, 0xdc, 0xba, 0x98)),
349
+ ).rejects.toThrow();
345
350
  });
346
351
 
347
352
  test('decode array (float32, strongly typed, optimized) [use typed array]', async () => {
@@ -352,7 +357,30 @@ test('decode array (float32, strongly typed, optimized) [use typed array]', asyn
352
357
 
353
358
  test('decode array (float64, strongly typed, optimized) [use typed array]', async () => {
354
359
  const actual = await decode(
355
- toBuffer('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
360
+ toBuffer(
361
+ '[',
362
+ '$',
363
+ 'D',
364
+ '#',
365
+ 'i',
366
+ 2,
367
+ 0x3f,
368
+ 0xd0,
369
+ 0x00,
370
+ 0x00,
371
+ 0x00,
372
+ 0x00,
373
+ 0x00,
374
+ 0x00,
375
+ 0x3f,
376
+ 0xc0,
377
+ 0x00,
378
+ 0x00,
379
+ 0x00,
380
+ 0x00,
381
+ 0x00,
382
+ 0x00,
383
+ ),
356
384
  );
357
385
  expect(actual).toBeInstanceOf(Float64Array);
358
386
  expect(actual).toEqual(Float64Array.from([0.25, 0.125]));
@@ -367,7 +395,11 @@ test('decode object', async () => {
367
395
  });
368
396
 
369
397
  test('decode object (with no-op)', async () => {
370
- expect(await decode(toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'))).toEqual({
398
+ expect(
399
+ await decode(
400
+ toBuffer('N', '{', 'N', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'N', 'i', 2, 'i', 1, 'c', 'i', 3, 'N', '}', 'N'),
401
+ ),
402
+ ).toEqual({
371
403
  a: 1,
372
404
  b: 2,
373
405
  c: 3,
@@ -379,7 +411,9 @@ test('decode array (empty, optimized)', async () => {
379
411
  });
380
412
 
381
413
  test('decode object (mixed, optimized)', async () => {
382
- expect(await decode(toBuffer('{', '#', 'i', 3, 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T'))).toEqual({
414
+ expect(
415
+ await decode(toBuffer('{', '#', 'i', 3, 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T')),
416
+ ).toEqual({
383
417
  a: 1,
384
418
  b: 'a',
385
419
  c: true,
@@ -71,7 +71,9 @@ test('encode float32 (too large integer)', async () => {
71
71
  });
72
72
 
73
73
  test('encode float64', async () => {
74
- expect(toArray(await encodeAsync(100_000.003_906_25))).toEqual(toArray('D', 0x40, 0xf8, 0x6a, 0x00, 0x10, 0x00, 0x00, 0x00));
74
+ expect(toArray(await encodeAsync(100_000.003_906_25))).toEqual(
75
+ toArray('D', 0x40, 0xf8, 0x6a, 0x00, 0x10, 0x00, 0x00, 0x00),
76
+ );
75
77
  });
76
78
 
77
79
  test('encode char', async () => {
@@ -187,15 +189,21 @@ test('encode array of objects of arrays', async () => {
187
189
  });
188
190
 
189
191
  test('encode array (int8 typed array)', async () => {
190
- expect(toArray(await encodeAsync(Int8Array.from([18, -2])))).toEqual(toArray('[', '$', 'i', '#', 'i', 2, 0x12, 0xfe));
192
+ expect(toArray(await encodeAsync(Int8Array.from([18, -2])))).toEqual(
193
+ toArray('[', '$', 'i', '#', 'i', 2, 0x12, 0xfe),
194
+ );
191
195
  });
192
196
 
193
197
  test('encode array (uint8 typed array)', async () => {
194
- expect(toArray(await encodeAsync(Uint8Array.from([18, 254])))).toEqual(toArray('[', '$', 'U', '#', 'i', 2, 0x12, 0xfe));
198
+ expect(toArray(await encodeAsync(Uint8Array.from([18, 254])))).toEqual(
199
+ toArray('[', '$', 'U', '#', 'i', 2, 0x12, 0xfe),
200
+ );
195
201
  });
196
202
 
197
203
  test('encode array (int16 typed array)', async () => {
198
- expect(toArray(await encodeAsync(Int16Array.from([4660, -292])))).toEqual(toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc));
204
+ expect(toArray(await encodeAsync(Int16Array.from([4660, -292])))).toEqual(
205
+ toArray('[', '$', 'I', '#', 'i', 2, 0x12, 0x34, 0xfe, 0xdc),
206
+ );
199
207
  });
200
208
 
201
209
  test('encode array (int32 typed array)', async () => {
@@ -212,7 +220,30 @@ test('encode array (float32 typed array)', async () => {
212
220
 
213
221
  test('encode array (float64 typed array)', async () => {
214
222
  expect(toArray(await encodeAsync(Float64Array.from([0.25, 0.125])))).toEqual(
215
- toArray('[', '$', 'D', '#', 'i', 2, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
223
+ toArray(
224
+ '[',
225
+ '$',
226
+ 'D',
227
+ '#',
228
+ 'i',
229
+ 2,
230
+ 0x3f,
231
+ 0xd0,
232
+ 0x00,
233
+ 0x00,
234
+ 0x00,
235
+ 0x00,
236
+ 0x00,
237
+ 0x00,
238
+ 0x3f,
239
+ 0xc0,
240
+ 0x00,
241
+ 0x00,
242
+ 0x00,
243
+ 0x00,
244
+ 0x00,
245
+ 0x00,
246
+ ),
216
247
  );
217
248
  });
218
249
 
@@ -237,7 +268,9 @@ test('encode array (int64 typed array)', async () => {
237
268
  });
238
269
 
239
270
  test('encode object', async () => {
240
- expect(toArray(await encodeAsync({ a: 1, b: 2, c: 3 }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'));
271
+ expect(toArray(await encodeAsync({ a: 1, b: 2, c: 3 }))).toEqual(
272
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'U', 2, 'i', 1, 'c', 'U', 3, '}'),
273
+ );
241
274
  });
242
275
 
243
276
  test('encode object (empty)', async () => {
@@ -249,11 +282,15 @@ test('encode object (empty key)', async () => {
249
282
  });
250
283
 
251
284
  test('encode object (mixed)', async () => {
252
- expect(toArray(await encodeAsync({ a: 1, b: 'a', c: true }))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
285
+ expect(toArray(await encodeAsync({ a: 1, b: 'a', c: true }))).toEqual(
286
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
287
+ );
253
288
  });
254
289
 
255
290
  test('encode object (only null values)', async () => {
256
- expect(toArray(await encodeAsync({ a: null, b: null, c: null }))).toEqual(toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'));
291
+ expect(toArray(await encodeAsync({ a: null, b: null, c: null }))).toEqual(
292
+ toArray('{', 'i', 1, 'a', 'Z', 'i', 1, 'b', 'Z', 'i', 1, 'c', 'Z', '}'),
293
+ );
257
294
  });
258
295
 
259
296
  test('encode object (skip prototype)', async () => {
@@ -261,7 +298,9 @@ test('encode object (skip prototype)', async () => {
261
298
  obj.a = 1;
262
299
  obj.b = 'a';
263
300
  obj.c = true;
264
- expect(toArray(await encodeAsync(obj))).toEqual(toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'));
301
+ expect(toArray(await encodeAsync(obj))).toEqual(
302
+ toArray('{', 'i', 1, 'a', 'U', 1, 'i', 1, 'b', 'C', 'a', 'i', 1, 'c', 'T', '}'),
303
+ );
265
304
  });
266
305
 
267
306
  test('encode object (skip symbol)', async () => {
@@ -307,7 +346,9 @@ test('encode huge typed array (16K)', async () => {
307
346
 
308
347
  test('encode huge typed array (~128M)', async () => {
309
348
  const obj = new Uint8Array(128 * 1024 * 1024 - 10);
310
- expect(toArray((await encodeAsync(obj)).slice(0, 10))).toEqual(toArray('[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xf6, 0));
349
+ expect(toArray((await encodeAsync(obj)).slice(0, 10))).toEqual(
350
+ toArray('[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xf6, 0),
351
+ );
311
352
  });
312
353
 
313
354
  test('encode huge typed array (256M + 1) [error]', async () => {
@@ -322,7 +363,9 @@ test('encode huge typed array (3G) [error]', async () => {
322
363
 
323
364
  test('encode huge data (~128M)', async () => {
324
365
  const obj = [new Uint8Array(128 * 1024 * 1024 - 20)];
325
- expect(toArray((await encodeAsync(obj)).subarray(0, 11))).toEqual(toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0));
366
+ expect(toArray((await encodeAsync(obj)).subarray(0, 11))).toEqual(
367
+ toArray('[', '[', '$', 'U', '#', 'l', 0x7, 0xff, 0xff, 0xec, 0),
368
+ );
326
369
  });
327
370
 
328
371
  test('encode huge data (256M + 1) [error]', async () => {
@@ -4,7 +4,10 @@ import { StringDecoder, decodeJs } from '../dist/common/string-decoder.js';
4
4
  /**
5
5
  * 测试编码
6
6
  */
7
- function testEncoding(/** @type {Pick<TextEncoder, 'encode'>} */ encoder, /** @type {Pick<TextDecoder, 'decode'>} */ decoder) {
7
+ function testEncoding(
8
+ /** @type {Pick<TextEncoder, 'encode'>} */ encoder,
9
+ /** @type {Pick<TextDecoder, 'decode'>} */ decoder,
10
+ ) {
8
11
  expect(decoder.decode(encoder.encode(''))).toEqual('');
9
12
  expect(decoder.decode(encoder.encode('p4'))).toEqual('p4');
10
13
  expect(decoder.decode(encoder.encode('t0'))).toEqual('t0');