cborg 2.0.4 → 3.0.0-alpha.1

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.
Files changed (135) hide show
  1. package/.github/dependabot.yml +16 -0
  2. package/.github/workflows/test-and-release.yml +63 -0
  3. package/CHANGELOG.md +332 -0
  4. package/bench/bench.js +117 -0
  5. package/bench/json.js +124 -0
  6. package/bench/package.json +8 -0
  7. package/lib/bin.js +1 -1
  8. package/package.json +29 -47
  9. package/types/lib/bin.d.ts +1 -0
  10. package/cjs/browser-test/appendix_a.js +0 -643
  11. package/cjs/browser-test/common.js +0 -24
  12. package/cjs/browser-test/node-test-bin.js +0 -348
  13. package/cjs/browser-test/noop-bin-test.js +0 -4
  14. package/cjs/browser-test/test-0uint.js +0 -158
  15. package/cjs/browser-test/test-1negint.js +0 -152
  16. package/cjs/browser-test/test-2bytes.js +0 -254
  17. package/cjs/browser-test/test-3string.js +0 -144
  18. package/cjs/browser-test/test-4array.js +0 -200
  19. package/cjs/browser-test/test-5map.js +0 -667
  20. package/cjs/browser-test/test-6tag.js +0 -75
  21. package/cjs/browser-test/test-7float.js +0 -253
  22. package/cjs/browser-test/test-bl.js +0 -91
  23. package/cjs/browser-test/test-cbor-vectors.js +0 -98
  24. package/cjs/browser-test/test-decode-errors.js +0 -77
  25. package/cjs/browser-test/test-fuzz.js +0 -56
  26. package/cjs/browser-test/test-json.js +0 -281
  27. package/cjs/browser-test/test-length.js +0 -63
  28. package/cjs/cborg.js +0 -14
  29. package/cjs/lib/0uint.js +0 -163
  30. package/cjs/lib/1negint.js +0 -63
  31. package/cjs/lib/2bytes.js +0 -62
  32. package/cjs/lib/3string.js +0 -46
  33. package/cjs/lib/4array.js +0 -51
  34. package/cjs/lib/5map.js +0 -51
  35. package/cjs/lib/6tag.js +0 -36
  36. package/cjs/lib/7float.js +0 -188
  37. package/cjs/lib/bin.js +0 -139
  38. package/cjs/lib/bl.js +0 -77
  39. package/cjs/lib/byte-utils.js +0 -245
  40. package/cjs/lib/common.js +0 -22
  41. package/cjs/lib/decode.js +0 -140
  42. package/cjs/lib/diagnostic.js +0 -124
  43. package/cjs/lib/encode.js +0 -248
  44. package/cjs/lib/is.js +0 -87
  45. package/cjs/lib/json/decode.js +0 -414
  46. package/cjs/lib/json/encode.js +0 -161
  47. package/cjs/lib/json/json.js +0 -12
  48. package/cjs/lib/jump.js +0 -174
  49. package/cjs/lib/length.js +0 -36
  50. package/cjs/lib/token.js +0 -46
  51. package/cjs/node-test/appendix_a.js +0 -643
  52. package/cjs/node-test/common.js +0 -24
  53. package/cjs/node-test/node-test-bin.js +0 -348
  54. package/cjs/node-test/noop-bin-test.js +0 -4
  55. package/cjs/node-test/test-0uint.js +0 -158
  56. package/cjs/node-test/test-1negint.js +0 -152
  57. package/cjs/node-test/test-2bytes.js +0 -254
  58. package/cjs/node-test/test-3string.js +0 -144
  59. package/cjs/node-test/test-4array.js +0 -200
  60. package/cjs/node-test/test-5map.js +0 -667
  61. package/cjs/node-test/test-6tag.js +0 -75
  62. package/cjs/node-test/test-7float.js +0 -253
  63. package/cjs/node-test/test-bl.js +0 -91
  64. package/cjs/node-test/test-cbor-vectors.js +0 -98
  65. package/cjs/node-test/test-decode-errors.js +0 -77
  66. package/cjs/node-test/test-fuzz.js +0 -56
  67. package/cjs/node-test/test-json.js +0 -281
  68. package/cjs/node-test/test-length.js +0 -63
  69. package/cjs/taglib.js +0 -44
  70. package/cli.js +0 -7
  71. package/esm/browser-test/appendix_a.js +0 -640
  72. package/esm/browser-test/common.js +0 -19
  73. package/esm/browser-test/node-test-bin.js +0 -339
  74. package/esm/browser-test/noop-bin-test.js +0 -1
  75. package/esm/browser-test/test-0uint.js +0 -155
  76. package/esm/browser-test/test-1negint.js +0 -149
  77. package/esm/browser-test/test-2bytes.js +0 -252
  78. package/esm/browser-test/test-3string.js +0 -141
  79. package/esm/browser-test/test-4array.js +0 -197
  80. package/esm/browser-test/test-5map.js +0 -664
  81. package/esm/browser-test/test-6tag.js +0 -78
  82. package/esm/browser-test/test-7float.js +0 -250
  83. package/esm/browser-test/test-bl.js +0 -84
  84. package/esm/browser-test/test-cbor-vectors.js +0 -95
  85. package/esm/browser-test/test-decode-errors.js +0 -69
  86. package/esm/browser-test/test-fuzz.js +0 -50
  87. package/esm/browser-test/test-json.js +0 -279
  88. package/esm/browser-test/test-length.js +0 -55
  89. package/esm/cborg.js +0 -12
  90. package/esm/lib/0uint.js +0 -152
  91. package/esm/lib/1negint.js +0 -55
  92. package/esm/lib/2bytes.js +0 -59
  93. package/esm/lib/3string.js +0 -43
  94. package/esm/lib/4array.js +0 -41
  95. package/esm/lib/5map.js +0 -41
  96. package/esm/lib/6tag.js +0 -27
  97. package/esm/lib/7float.js +0 -179
  98. package/esm/lib/bin.js +0 -137
  99. package/esm/lib/bl.js +0 -74
  100. package/esm/lib/byte-utils.js +0 -228
  101. package/esm/lib/common.js +0 -19
  102. package/esm/lib/decode.js +0 -139
  103. package/esm/lib/diagnostic.js +0 -123
  104. package/esm/lib/encode.js +0 -246
  105. package/esm/lib/is.js +0 -81
  106. package/esm/lib/json/decode.js +0 -413
  107. package/esm/lib/json/encode.js +0 -160
  108. package/esm/lib/json/json.js +0 -10
  109. package/esm/lib/jump.js +0 -168
  110. package/esm/lib/length.js +0 -31
  111. package/esm/lib/token.js +0 -43
  112. package/esm/node-test/appendix_a.js +0 -640
  113. package/esm/node-test/common.js +0 -19
  114. package/esm/node-test/node-test-bin.js +0 -339
  115. package/esm/node-test/noop-bin-test.js +0 -1
  116. package/esm/node-test/test-0uint.js +0 -155
  117. package/esm/node-test/test-1negint.js +0 -149
  118. package/esm/node-test/test-2bytes.js +0 -252
  119. package/esm/node-test/test-3string.js +0 -141
  120. package/esm/node-test/test-4array.js +0 -197
  121. package/esm/node-test/test-5map.js +0 -664
  122. package/esm/node-test/test-6tag.js +0 -78
  123. package/esm/node-test/test-7float.js +0 -250
  124. package/esm/node-test/test-bl.js +0 -84
  125. package/esm/node-test/test-cbor-vectors.js +0 -95
  126. package/esm/node-test/test-decode-errors.js +0 -69
  127. package/esm/node-test/test-fuzz.js +0 -50
  128. package/esm/node-test/test-json.js +0 -279
  129. package/esm/node-test/test-length.js +0 -55
  130. package/esm/package.json +0 -4
  131. package/esm/taglib.js +0 -37
  132. package/index.js +0 -1
  133. package/json +0 -1
  134. package/length +0 -1
  135. package/taglib +0 -1
@@ -1,664 +0,0 @@
1
- import chai from 'chai';
2
- import {
3
- decode,
4
- encode
5
- } from '../cborg.js';
6
- import {
7
- fromHex,
8
- toHex
9
- } from '../lib/byte-utils.js';
10
- const {assert} = chai;
11
- const fixtures = [
12
- {
13
- data: 'a0',
14
- expected: {},
15
- type: 'map empty'
16
- },
17
- {
18
- data: 'a0',
19
- expected: new Map(),
20
- type: 'map empty (useMaps)',
21
- useMaps: true
22
- },
23
- {
24
- data: 'a1616101',
25
- expected: { a: 1 },
26
- type: 'map 1 pair'
27
- },
28
- {
29
- data: 'a161316161',
30
- expected: { 1: 'a' },
31
- type: 'map 1 pair (rev)'
32
- },
33
- {
34
- data: 'a1016161',
35
- expected: toMap([[
36
- 1,
37
- 'a'
38
- ]]),
39
- type: 'map 1 pair (int key as Map w/ useMaps)',
40
- useMaps: true
41
- },
42
- {
43
- data: 'a243010203633132334302030463323334',
44
- expected: toMap([
45
- [
46
- Uint8Array.from([
47
- 1,
48
- 2,
49
- 3
50
- ]),
51
- '123'
52
- ],
53
- [
54
- Uint8Array.from([
55
- 2,
56
- 3,
57
- 4
58
- ]),
59
- '234'
60
- ]
61
- ]),
62
- type: 'map 2 pair (bytes keys Map w/ useMaps)',
63
- useMaps: true
64
- },
65
- {
66
- data: 'a1666f626a656374a16477697468a26134666e6573746564676f626a65637473a161216121',
67
- expected: {
68
- object: {
69
- with: {
70
- 4: 'nested',
71
- objects: { '!': '!' }
72
- }
73
- }
74
- },
75
- type: 'map nested'
76
- },
77
- {
78
- data: 'a1666f626a656374a16477697468a204666e6573746564676f626a65637473a161216121',
79
- expected: toMap([[
80
- 'object',
81
- toMap([[
82
- 'with',
83
- toMap([
84
- [
85
- 4,
86
- 'nested'
87
- ],
88
- [
89
- 'objects',
90
- toMap([[
91
- '!',
92
- '!'
93
- ]])
94
- ]
95
- ])
96
- ]])
97
- ]]),
98
- type: 'map nested w/ useMaps',
99
- useMaps: true
100
- },
101
- {
102
- data: 'ae636f6e651b0016db6db6db6db763736978206374656e3b0016db6db6db6db76374776f1a0001000064666976650064666f757202646e696e653aa5f702b365656967687438ff65736576656e226574687265651901f466656c6576656e426131667477656c76656fc48c6175657320c39f76c49b74652168666f75727465656ea4616664666f7572616f016174026274680368746869727465656e840203046466697665',
103
- encode: {
104
- one: Number.MAX_SAFE_INTEGER / 1.4,
105
- two: 65536,
106
- three: 500,
107
- four: 2,
108
- five: 0,
109
- six: -1,
110
- seven: -3,
111
- eight: -256,
112
- nine: -2784428724,
113
- ten: Number.MIN_SAFE_INTEGER / 1.4 - 1,
114
- eleven: new TextEncoder().encode('a1'),
115
- twelve: 'Čaues ßvěte!',
116
- thirteen: [
117
- 2,
118
- 3,
119
- 4,
120
- 'five'
121
- ],
122
- fourteen: {
123
- o: 1,
124
- t: 2,
125
- th: 3,
126
- f: 'four'
127
- }
128
- },
129
- expected: {
130
- one: Number.MAX_SAFE_INTEGER / 1.4,
131
- six: -1,
132
- ten: Number.MIN_SAFE_INTEGER / 1.4 - 1,
133
- two: 65536,
134
- five: 0,
135
- four: 2,
136
- nine: -2784428724,
137
- eight: -256,
138
- seven: -3,
139
- three: 500,
140
- eleven: new TextEncoder().encode('a1'),
141
- twelve: 'Čaues ßvěte!',
142
- fourteen: {
143
- f: 'four',
144
- o: 1,
145
- t: 2,
146
- th: 3
147
- },
148
- thirteen: [
149
- 2,
150
- 3,
151
- 4,
152
- 'five'
153
- ]
154
- },
155
- type: 'map with complex entries',
156
- label: '{}'
157
- },
158
- {
159
- data: 'ad01636f6e65026374776f1901f46c666976652068756e647265641902586b7369782068756e647265641a00010000636269671b0016db6db6db6db76662696767657220696d696e7573206f6e6521696d696e75732074776f38ff781f6d696e75732074776f2068756e6472656420616e64206669667479207369783901f4781a6d696e757820666976652068756e6472656420616e64206f6e653901f5781a6d696e757820666976652068756e6472656420616e642074776f3aa5f702b367626967206e65673b0016db6db6db6db76a626967676572206e6567',
160
- encode: toMap([
161
- [
162
- 2,
163
- 'two'
164
- ],
165
- [
166
- 1,
167
- 'one'
168
- ],
169
- [
170
- -2,
171
- 'minus two'
172
- ],
173
- [
174
- -1,
175
- 'minus one'
176
- ],
177
- [
178
- 600,
179
- 'six hundred'
180
- ],
181
- [
182
- 500,
183
- 'five hundred'
184
- ],
185
- [
186
- -256,
187
- 'minus two hundred and fifty six'
188
- ],
189
- [
190
- -502,
191
- 'minux five hundred and two'
192
- ],
193
- [
194
- -501,
195
- 'minux five hundred and one'
196
- ],
197
- [
198
- 65536,
199
- 'big'
200
- ],
201
- [
202
- -2784428724,
203
- 'big neg'
204
- ],
205
- [
206
- 6433713753386423,
207
- 'bigger'
208
- ],
209
- [
210
- -6433713753386424,
211
- 'bigger neg'
212
- ]
213
- ]),
214
- expected: toMap([
215
- [
216
- 1,
217
- 'one'
218
- ],
219
- [
220
- 2,
221
- 'two'
222
- ],
223
- [
224
- 500,
225
- 'five hundred'
226
- ],
227
- [
228
- 600,
229
- 'six hundred'
230
- ],
231
- [
232
- 65536,
233
- 'big'
234
- ],
235
- [
236
- 6433713753386423,
237
- 'bigger'
238
- ],
239
- [
240
- -1,
241
- 'minus one'
242
- ],
243
- [
244
- -2,
245
- 'minus two'
246
- ],
247
- [
248
- -256,
249
- 'minus two hundred and fifty six'
250
- ],
251
- [
252
- -501,
253
- 'minux five hundred and one'
254
- ],
255
- [
256
- -502,
257
- 'minux five hundred and two'
258
- ],
259
- [
260
- -2784428724,
261
- 'big neg'
262
- ],
263
- [
264
- -6433713753386424,
265
- 'bigger neg'
266
- ]
267
- ]),
268
- type: 'map with ints and negints',
269
- useMaps: true
270
- },
271
- {
272
- data: 'a44104636f6e65430102026374776f430102036574687265654301020464666f7572',
273
- encode: toMap([
274
- [
275
- Uint8Array.from([
276
- 1,
277
- 2,
278
- 3
279
- ]),
280
- 'three'
281
- ],
282
- [
283
- Uint8Array.from([4]),
284
- 'one'
285
- ],
286
- [
287
- Uint8Array.from([
288
- 1,
289
- 2,
290
- 4
291
- ]),
292
- 'four'
293
- ],
294
- [
295
- Uint8Array.from([
296
- 1,
297
- 2,
298
- 2
299
- ]),
300
- 'two'
301
- ]
302
- ]),
303
- expected: toMap([
304
- [
305
- Uint8Array.from([4]),
306
- 'one'
307
- ],
308
- [
309
- Uint8Array.from([
310
- 1,
311
- 2,
312
- 2
313
- ]),
314
- 'two'
315
- ],
316
- [
317
- Uint8Array.from([
318
- 1,
319
- 2,
320
- 3
321
- ]),
322
- 'three'
323
- ],
324
- [
325
- Uint8Array.from([
326
- 1,
327
- 2,
328
- 4
329
- ]),
330
- 'four'
331
- ]
332
- ]),
333
- type: 'map with bytes keys',
334
- useMaps: true
335
- },
336
- {
337
- data: 'b801616101',
338
- expected: { a: 1 },
339
- type: 'map 1 pair, length8',
340
- strict: false
341
- },
342
- {
343
- data: 'b90001616101',
344
- expected: { a: 1 },
345
- type: 'map 1 pair, length16',
346
- strict: false
347
- },
348
- {
349
- data: 'ba00000001616101',
350
- expected: { a: 1 },
351
- type: 'map 1 pair, length32',
352
- strict: false
353
- },
354
- {
355
- data: 'bb0000000000000001616101',
356
- expected: { a: 1 },
357
- type: 'map 1 pair, length64',
358
- strict: false
359
- }
360
- ];
361
- function toMap(arr) {
362
- const m = new Map();
363
- for (const [key, value] of arr) {
364
- m.set(key, value);
365
- }
366
- return m;
367
- }
368
- function entries(map) {
369
- function nest(a) {
370
- for (const e of a) {
371
- e[0] = entries(e[0]);
372
- e[1] = entries(e[1]);
373
- }
374
- return a;
375
- }
376
- if (Object.getPrototypeOf(map) === Map.prototype) {
377
- return nest([...map.entries()]);
378
- }
379
- if (typeof map === 'object') {
380
- return nest([...Object.entries(map)]);
381
- }
382
- return map;
383
- }
384
- describe('map', () => {
385
- describe('decode', () => {
386
- for (const fixture of fixtures) {
387
- const data = fromHex(fixture.data);
388
- it(`should decode ${ fixture.type }=${ fixture.label || JSON.stringify(fixture.expected) }`, () => {
389
- let options = fixture.useMaps ? { useMaps: true } : undefined;
390
- const decoded = decode(data, options);
391
- if (fixture.useMaps) {
392
- assert.strictEqual(Object.getPrototypeOf(decoded), Map.prototype, 'is Map');
393
- } else {
394
- assert.isObject(decoded, 'is object');
395
- }
396
- assert.deepStrictEqual(entries(decoded), entries(fixture.expected), `decode ${ fixture.type }`);
397
- options = Object.assign({ strict: true }, options);
398
- if (fixture.strict === false) {
399
- assert.throws(() => decode(data, options), Error, 'CBOR decode error: integer encoded in more bytes than necessary (strict decode)');
400
- } else {
401
- assert.deepStrictEqual(entries(decode(data, options)), entries(fixture.expected), `decode ${ fixture.type }`);
402
- }
403
- });
404
- it('should fail to decode very large length', () => {
405
- assert.throws(() => decode(fromHex('bba5f702b3a5f70201616101')), /CBOR decode error: 64-bit integer map lengths not supported/);
406
- });
407
- }
408
- it('errors', () => {
409
- assert.throws(() => decode(fromHex('a1016161')), /non-string keys not supported \(got number\)/);
410
- });
411
- });
412
- describe('encode', () => {
413
- for (const fixture of fixtures) {
414
- it(`should encode ${ fixture.type }=${ fixture.label || JSON.stringify(fixture.expected) }`, () => {
415
- const toEncode = fixture.encode || fixture.expected;
416
- if (fixture.unsafe) {
417
- assert.throws(encode.bind(null, toEncode), Error, /^CBOR encode error: number too large to encode \(\d+\)$/);
418
- } else if (fixture.strict === false || fixture.roundtrip === false) {
419
- assert.notDeepEqual(toHex(encode(toEncode)), fixture.data, `encode ${ fixture.type } !strict`);
420
- } else {
421
- assert.strictEqual(toHex(encode(toEncode)), fixture.data, `encode ${ fixture.type }`);
422
- }
423
- });
424
- }
425
- });
426
- describe('roundtrip', () => {
427
- for (const fixture of fixtures) {
428
- if (!fixture.unsafe && fixture.strict !== false && fixture.roundtrip !== false) {
429
- it(`should roundtrip ${ fixture.type }=${ fixture.label || JSON.stringify(fixture.expected) }`, () => {
430
- const toEncode = fixture.encode || fixture.expected;
431
- const options = fixture.useMaps ? { useMaps: true } : undefined;
432
- const rt = decode(encode(toEncode), options);
433
- if (fixture.useMaps) {
434
- assert.strictEqual(Object.getPrototypeOf(rt), Map.prototype, 'is Map');
435
- } else {
436
- assert.isObject(rt, 'is object');
437
- }
438
- assert.deepStrictEqual(entries(rt), entries(fixture.expected), `roundtrip ${ fixture.type }`);
439
- });
440
- }
441
- }
442
- });
443
- describe('specials', () => {
444
- it('can decode indefinite length items', () => {
445
- assert.deepStrictEqual(decode(fromHex('bf616f01617402ff')), {
446
- o: 1,
447
- t: 2
448
- });
449
- });
450
- it('can switch off indefinite length support', () => {
451
- assert.throws(() => decode(fromHex('bf616f01617402ff'), { allowIndefinite: false }), /indefinite/);
452
- });
453
- });
454
- describe('sorting', () => {
455
- it('sorts int map keys', () => {
456
- assert.strictEqual(toHex(encode(new Map([
457
- [
458
- 1,
459
- 1
460
- ],
461
- [
462
- 2,
463
- 2
464
- ]
465
- ]))), 'a201010202');
466
- assert.strictEqual(toHex(encode(new Map([
467
- [
468
- 2,
469
- 1
470
- ],
471
- [
472
- 1,
473
- 2
474
- ]
475
- ]))), 'a201020201');
476
- });
477
- it('sorts negint map keys', () => {
478
- assert.strictEqual(toHex(encode(new Map([
479
- [
480
- -1,
481
- 1
482
- ],
483
- [
484
- -2,
485
- 2
486
- ]
487
- ]))), 'a220012102');
488
- assert.strictEqual(toHex(encode(new Map([
489
- [
490
- -2,
491
- 1
492
- ],
493
- [
494
- -1,
495
- 2
496
- ]
497
- ]))), 'a220022101');
498
- });
499
- it('sorts bytes map keys', () => {
500
- assert.strictEqual(toHex(encode(new Map([
501
- [
502
- Uint8Array.from([
503
- 1,
504
- 2
505
- ]),
506
- 1
507
- ],
508
- [
509
- Uint8Array.from([
510
- 2,
511
- 1
512
- ]),
513
- 2
514
- ]
515
- ]))), 'a24201020142020102');
516
- assert.strictEqual(toHex(encode(new Map([
517
- [
518
- Uint8Array.from([
519
- 2,
520
- 1
521
- ]),
522
- 1
523
- ],
524
- [
525
- Uint8Array.from([
526
- 1,
527
- 2
528
- ]),
529
- 2
530
- ]
531
- ]))), 'a24201020242020101');
532
- assert.strictEqual(toHex(encode(new Map([
533
- [
534
- Uint8Array.from([
535
- 1,
536
- 2
537
- ]),
538
- 1
539
- ],
540
- [
541
- Uint8Array.from([
542
- 2,
543
- 1
544
- ]),
545
- 2
546
- ],
547
- [
548
- Uint8Array.from([200]),
549
- 3
550
- ]
551
- ]))), 'a341c8034201020142020102');
552
- });
553
- it('sorts bytes map keys', () => {
554
- assert.strictEqual(toHex(encode(new Map([
555
- [
556
- Uint8Array.from([
557
- 1,
558
- 2
559
- ]),
560
- 1
561
- ],
562
- [
563
- Uint8Array.from([
564
- 2,
565
- 1
566
- ]),
567
- 2
568
- ]
569
- ]))), 'a24201020142020102');
570
- assert.strictEqual(toHex(encode(new Map([
571
- [
572
- Uint8Array.from([
573
- 2,
574
- 1
575
- ]),
576
- 1
577
- ],
578
- [
579
- Uint8Array.from([
580
- 1,
581
- 2
582
- ]),
583
- 2
584
- ]
585
- ]))), 'a24201020242020101');
586
- assert.strictEqual(toHex(encode(new Map([
587
- [
588
- Uint8Array.from([
589
- 1,
590
- 2
591
- ]),
592
- 1
593
- ],
594
- [
595
- Uint8Array.from([
596
- 2,
597
- 1
598
- ]),
599
- 2
600
- ],
601
- [
602
- Uint8Array.from([200]),
603
- 3
604
- ]
605
- ]))), 'a341c8034201020142020102');
606
- });
607
- it('sorts array map keys (length only)', () => {
608
- assert.strictEqual(toHex(encode(new Map([
609
- [
610
- [1],
611
- 1
612
- ],
613
- [
614
- [
615
- 1,
616
- 1
617
- ],
618
- 2
619
- ]
620
- ]))), 'a281010182010102');
621
- assert.strictEqual(toHex(encode(new Map([
622
- [
623
- [
624
- 1,
625
- 1
626
- ],
627
- 1
628
- ],
629
- [
630
- [1],
631
- 2
632
- ]
633
- ]))), 'a281010282010101');
634
- });
635
- it('sorts map map keys (length only)', () => {
636
- assert.strictEqual(toHex(encode(new Map([
637
- [
638
- { a: 1 },
639
- 1
640
- ],
641
- [
642
- {
643
- a: 1,
644
- b: 1
645
- },
646
- 2
647
- ]
648
- ]))), 'a2a161610101a261610161620102');
649
- assert.strictEqual(toHex(encode(new Map([
650
- [
651
- {
652
- a: 1,
653
- b: 1
654
- },
655
- 1
656
- ],
657
- [
658
- { a: 1 },
659
- 2
660
- ]
661
- ]))), 'a2a161610102a261610161620101');
662
- });
663
- });
664
- });