lib0 0.2.46 → 0.2.49

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 (71) hide show
  1. package/README.md +1 -0
  2. package/array.d.ts +1 -0
  3. package/array.d.ts.map +1 -1
  4. package/array.js +2 -0
  5. package/array.test.d.ts +1 -0
  6. package/array.test.d.ts.map +1 -1
  7. package/decoding.js +2 -2
  8. package/dist/{array-b2d24238.cjs → array-acefe0f2.cjs} +6 -2
  9. package/dist/{array-b2d24238.cjs.map → array-acefe0f2.cjs.map} +1 -1
  10. package/dist/array.cjs +2 -1
  11. package/dist/array.cjs.map +1 -1
  12. package/dist/array.d.ts +1 -0
  13. package/dist/array.d.ts.map +1 -1
  14. package/dist/array.test.d.ts +1 -0
  15. package/dist/array.test.d.ts.map +1 -1
  16. package/dist/{broadcastchannel-7da37795.cjs → broadcastchannel-1ac6c212.cjs} +2 -2
  17. package/dist/{broadcastchannel-7da37795.cjs.map → broadcastchannel-1ac6c212.cjs.map} +1 -1
  18. package/dist/broadcastchannel.cjs +2 -2
  19. package/dist/{buffer-b0dea3b0.cjs → buffer-c98f67d5.cjs} +4 -4
  20. package/dist/buffer-c98f67d5.cjs.map +1 -0
  21. package/dist/buffer.cjs +1 -1
  22. package/dist/component.cjs +3 -3
  23. package/dist/decoding.cjs +1 -1
  24. package/dist/{diff-233747fa.cjs → diff-2593547b.cjs} +2 -2
  25. package/dist/{diff-233747fa.cjs.map → diff-2593547b.cjs.map} +1 -1
  26. package/dist/diff.cjs +3 -3
  27. package/dist/encoding.cjs +1 -1
  28. package/dist/encoding.test.d.ts +1 -0
  29. package/dist/encoding.test.d.ts.map +1 -1
  30. package/dist/{function-f8acb5f5.cjs → function-e4045b1d.cjs} +2 -2
  31. package/dist/{function-f8acb5f5.cjs.map → function-e4045b1d.cjs.map} +1 -1
  32. package/dist/function.cjs +2 -2
  33. package/dist/index.cjs +10 -10
  34. package/dist/{iterator-fe01d209.cjs → iterator-9fc627c1.cjs} +1 -4
  35. package/dist/iterator-9fc627c1.cjs.map +1 -0
  36. package/dist/iterator.cjs +1 -1
  37. package/dist/iterator.d.ts.map +1 -1
  38. package/dist/{logging-f6d41f58.cjs → logging-0a4d8595.cjs} +2 -2
  39. package/dist/{logging-f6d41f58.cjs.map → logging-0a4d8595.cjs.map} +1 -1
  40. package/dist/logging.cjs +3 -3
  41. package/dist/metric.d.ts.map +1 -1
  42. package/dist/observable.cjs +1 -1
  43. package/dist/{prng-25602bac.cjs → prng-1aa0a1bc.cjs} +2 -2
  44. package/dist/{prng-25602bac.cjs.map → prng-1aa0a1bc.cjs.map} +1 -1
  45. package/dist/prng.cjs +2 -2
  46. package/dist/test.cjs +34 -6
  47. package/dist/test.cjs.map +1 -1
  48. package/dist/test.js +34 -6
  49. package/dist/test.js.map +1 -1
  50. package/dist/testing.cjs +6 -6
  51. package/dist/{tree-92f764b3.cjs → tree-b67c7947.cjs} +9 -2
  52. package/dist/tree-b67c7947.cjs.map +1 -0
  53. package/dist/tree.cjs +1 -1
  54. package/dist/tree.d.ts +13 -5
  55. package/dist/tree.d.ts.map +1 -1
  56. package/dist/{websocket-08bd4c7b.cjs → websocket-57086be8.cjs} +1 -1
  57. package/dist/{websocket-08bd4c7b.cjs.map → websocket-57086be8.cjs.map} +1 -1
  58. package/dist/websocket.cjs +2 -2
  59. package/encoding.js +1 -1
  60. package/encoding.test.d.ts +1 -0
  61. package/encoding.test.d.ts.map +1 -1
  62. package/iterator.d.ts.map +1 -1
  63. package/iterator.js +0 -3
  64. package/metric.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/tree.d.ts +13 -5
  67. package/tree.d.ts.map +1 -1
  68. package/tree.js +8 -1
  69. package/dist/buffer-b0dea3b0.cjs.map +0 -1
  70. package/dist/iterator-fe01d209.cjs.map +0 -1
  71. package/dist/tree-92f764b3.cjs.map +0 -1
package/dist/test.js CHANGED
@@ -862,6 +862,8 @@
862
862
  */
863
863
  const flatten = arr => arr.reduce((acc, val) => acc.concat(val), []);
864
864
 
865
+ const isArray = Array.isArray;
866
+
865
867
  /**
866
868
  * Utility functions for working with EcmaScript objects.
867
869
  *
@@ -2347,7 +2349,7 @@
2347
2349
  writeVarString(encoder, data);
2348
2350
  break
2349
2351
  case 'number':
2350
- if (isInteger(data) && data <= BITS31) {
2352
+ if (isInteger(data) && abs(data) <= BITS31) {
2351
2353
  // TYPE 125: INTEGER
2352
2354
  write(encoder, 125);
2353
2355
  writeVarInt(encoder, data);
@@ -2924,7 +2926,7 @@
2924
2926
  return num >>> 0 // return unsigned number!
2925
2927
  }
2926
2928
  /* istanbul ignore if */
2927
- if (len > 35) {
2929
+ if (len > 53) {
2928
2930
  throw new Error('Integer out of range!')
2929
2931
  }
2930
2932
  }
@@ -2958,7 +2960,7 @@
2958
2960
  return sign * (num >>> 0)
2959
2961
  }
2960
2962
  /* istanbul ignore if */
2961
- if (len > 41) {
2963
+ if (len > 53) {
2962
2964
  throw new Error('Integer out of range!')
2963
2965
  }
2964
2966
  }
@@ -4304,10 +4306,23 @@
4304
4306
  compareArrays(flatten(arr), [1, 2, 3, 4]);
4305
4307
  };
4306
4308
 
4309
+ /**
4310
+ * @param {t.TestCase} tc
4311
+ */
4312
+ const testIsArray = tc => {
4313
+ assert(isArray([]));
4314
+ assert(isArray([1]));
4315
+ assert(isArray(Array.from(new Set([3]))));
4316
+ assert(!isArray(1));
4317
+ assert(!isArray(0));
4318
+ assert(!isArray(''));
4319
+ };
4320
+
4307
4321
  var array = /*#__PURE__*/Object.freeze({
4308
4322
  __proto__: null,
4309
4323
  testAppend: testAppend,
4310
- testflatten: testflatten
4324
+ testflatten: testflatten,
4325
+ testIsArray: testIsArray
4311
4326
  });
4312
4327
 
4313
4328
  const testLogging = () => {
@@ -4590,8 +4605,8 @@
4590
4605
  }
4591
4606
  });
4592
4607
  });
4608
+ assert(durationConcatElements < durationConcatElementsNative * 1.3, '1.3x faster. We expect that the native approach is slower. If this fails, our expectantion is not met in your javascript environment. Please report this issue.');
4593
4609
  assert(durationConcatElements < durationSingleElements, 'We expect that the second approach is faster. If this fails, our expectantion is not met in your javascript environment. Please report this issue.');
4594
- assert(durationConcatElements < durationConcatElementsNative * 1.3, 'We expect that the native approach is slower. If this fails, our expectantion is not met in your javascript environment. Please report this issue.');
4595
4610
  };
4596
4611
 
4597
4612
  /**
@@ -5072,6 +5087,18 @@
5072
5087
  }
5073
5088
  };
5074
5089
 
5090
+ /**
5091
+ * @param {t.TestCase} tc
5092
+ */
5093
+ const testLargeNumberAnyEncoding = tc => {
5094
+ const encoder = createEncoder();
5095
+ const num = -2.2062063918362897e+50;
5096
+ writeAny(encoder, num);
5097
+ const decoder = createDecoder(toUint8Array(encoder));
5098
+ const readNum = readAny(decoder);
5099
+ assert(readNum === num);
5100
+ };
5101
+
5075
5102
  var encoding = /*#__PURE__*/Object.freeze({
5076
5103
  __proto__: null,
5077
5104
  testGolangBinaryEncodingCompatibility: testGolangBinaryEncodingCompatibility,
@@ -5102,7 +5129,8 @@
5102
5129
  testIntDiffRleEncoder: testIntDiffRleEncoder,
5103
5130
  testIntEncoders: testIntEncoders,
5104
5131
  testIntDiffEncoder: testIntDiffEncoder,
5105
- testStringDecoder: testStringDecoder
5132
+ testStringDecoder: testStringDecoder,
5133
+ testLargeNumberAnyEncoding: testLargeNumberAnyEncoding
5106
5134
  });
5107
5135
 
5108
5136
  /**