protobufjs 8.7.1 → 8.7.2

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v8.7.1 (c) 2016, daniel wirtz
3
- * compiled mon, 13 jul 2026 11:04:12 utc
2
+ * protobuf.js v8.7.2 (c) 2016, daniel wirtz
3
+ * compiled sat, 08 aug 2026 13:15:56 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -472,9 +472,18 @@ Reader.prototype.double = function read_double() {
472
472
  */
473
473
  Reader.prototype.uint32s = function read_uint32s(array) {
474
474
  if (array === undefined) array = [];
475
- var end = this.uint32() + this.pos;
476
- while (this.pos < end)
477
- array.push(this.uint32());
475
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
476
+ while (pos < end) {
477
+ value = buf[pos++];
478
+ if (value < 128)
479
+ array.push(value);
480
+ else {
481
+ this.pos = pos - 1;
482
+ array.push(this.uint32());
483
+ pos = this.pos;
484
+ }
485
+ }
486
+ this.pos = pos;
478
487
  return array;
479
488
  };
480
489
 
@@ -485,9 +494,18 @@ Reader.prototype.uint32s = function read_uint32s(array) {
485
494
  */
486
495
  Reader.prototype.int32s = function read_int32s(array) {
487
496
  if (array === undefined) array = [];
488
- var end = this.uint32() + this.pos;
489
- while (this.pos < end)
490
- array.push(this.int32());
497
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
498
+ while (pos < end) {
499
+ value = buf[pos++];
500
+ if (value < 128)
501
+ array.push(value);
502
+ else {
503
+ this.pos = pos - 1;
504
+ array.push(this.int32());
505
+ pos = this.pos;
506
+ }
507
+ }
508
+ this.pos = pos;
491
509
  return array;
492
510
  };
493
511
 
@@ -511,9 +529,18 @@ Reader.prototype.sint32s = function read_sint32s(array) {
511
529
  */
512
530
  Reader.prototype.bools = function read_bools(array) {
513
531
  if (array === undefined) array = [];
514
- var end = this.uint32() + this.pos;
515
- while (this.pos < end)
516
- array.push(this.bool());
532
+ var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
533
+ while (pos < end) {
534
+ value = buf[pos++];
535
+ if (value < 128)
536
+ array.push(value !== 0);
537
+ else {
538
+ this.pos = pos - 1;
539
+ array.push(this.bool());
540
+ pos = this.pos;
541
+ }
542
+ }
543
+ this.pos = pos;
517
544
  return array;
518
545
  };
519
546
 
@@ -2563,7 +2590,6 @@ function pool(alloc, slice, size) {
2563
2590
  * @namespace
2564
2591
  */
2565
2592
  var utf8 = exports,
2566
- replacementChar = "\ufffd",
2567
2593
  looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }),
2568
2594
  strictDecoder;
2569
2595
  var TEXT_DECODER_MIN_LENGTH = 64;
@@ -2598,31 +2624,6 @@ utf8.length = function utf8_length(string) {
2598
2624
  return len;
2599
2625
  };
2600
2626
 
2601
- function utf8_read_js(buffer, start, end, str) {
2602
- for (var i = start; i < end;) {
2603
- var t = buffer[i++];
2604
- if (t <= 0x7F) {
2605
- str += String.fromCharCode(t);
2606
- } else if (t >= 0xC0 && t < 0xE0) {
2607
- var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
2608
- str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
2609
- } else if (t >= 0xE0 && t < 0xF0) {
2610
- var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
2611
- str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
2612
- } else if (t >= 0xF0) {
2613
- var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
2614
- if (t2 < 0x10000 || t2 > 0x10FFFF)
2615
- str += replacementChar;
2616
- else {
2617
- t2 -= 0x10000;
2618
- str += String.fromCharCode(0xD800 + (t2 >> 10));
2619
- str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
2620
- }
2621
- }
2622
- }
2623
- return str;
2624
- }
2625
-
2626
2627
  function utf8_read_decoder(decoder, buffer, start, end) {
2627
2628
  var source = start === 0 && end === buffer.length
2628
2629
  ? buffer
@@ -2657,14 +2658,14 @@ utf8.read = function utf8_read_loose(buffer, start, end) {
2657
2658
  c7 = buffer[i + 6];
2658
2659
  c8 = buffer[i + 7];
2659
2660
  if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
2660
- return utf8_read_js(buffer, i, end, str);
2661
+ return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2661
2662
  str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
2662
2663
  }
2663
2664
 
2664
2665
  for (; i < end; ++i) {
2665
2666
  c1 = buffer[i];
2666
2667
  if (c1 & 0x80)
2667
- return utf8_read_js(buffer, i, end, str);
2668
+ return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2668
2669
  str += String.fromCharCode(c1);
2669
2670
  }
2670
2671
 
@@ -2775,7 +2776,7 @@ function Writer() {
2775
2776
  * Backing buffer.
2776
2777
  * @type {Uint8Array}
2777
2778
  */
2778
- this.buf = this.constructor.alloc(64);
2779
+ this.buf = this.constructor.alloc(Writer.initialBufferSize);
2779
2780
 
2780
2781
  /**
2781
2782
  * Cached DataView over {@link Writer#buf}.
@@ -2790,6 +2791,12 @@ function Writer() {
2790
2791
  this.states = null;
2791
2792
  }
2792
2793
 
2794
+ /**
2795
+ * Initial backing buffer size in bytes. Defaults to 128.
2796
+ * @type {number}
2797
+ */
2798
+ Writer.initialBufferSize = 128;
2799
+
2793
2800
  /**
2794
2801
  * Current write position.
2795
2802
  * @name Writer#len