seroval 1.6.8 → 1.6.9

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.
@@ -769,44 +769,7 @@ const SPECIAL_REF_STRING = {
769
769
  [5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
770
770
  };
771
771
  //#endregion
772
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
773
- function _checkPrivateRedeclaration(e, t) {
774
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
775
- }
776
- //#endregion
777
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
778
- function _classPrivateMethodInitSpec(e, a) {
779
- _checkPrivateRedeclaration(e, a), a.add(e);
780
- }
781
- //#endregion
782
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
783
- function _classPrivateFieldInitSpec(e, t, a) {
784
- _checkPrivateRedeclaration(e, t), t.set(e, a);
785
- }
786
- //#endregion
787
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
788
- function _assertClassBrand(e, t, n) {
789
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
790
- throw new TypeError("Private element is not present on this object");
791
- }
792
- //#endregion
793
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
794
- function _classPrivateFieldGet2(s, a) {
795
- return s.get(_assertClassBrand(s, a));
796
- }
797
- //#endregion
798
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
799
- function _classPrivateFieldSet2(s, a, r) {
800
- return s.set(_assertClassBrand(s, a), r), r;
801
- }
802
- //#endregion
803
772
  //#region src/core/stream.ts
804
- var _buffer = /* @__PURE__ */ new WeakMap();
805
- var _listeners = /* @__PURE__ */ new WeakMap();
806
- var _alive = /* @__PURE__ */ new WeakMap();
807
- var _success = /* @__PURE__ */ new WeakMap();
808
- var _count = /* @__PURE__ */ new WeakMap();
809
- var _Stream_brand = /* @__PURE__ */ new WeakSet();
810
773
  /**
811
774
  * An internal class rather than a tagged POJO: identity is checked with
812
775
  * `instanceof`, which untrusted input cannot forge (the class is not exported).
@@ -820,75 +783,68 @@ var _Stream_brand = /* @__PURE__ */ new WeakSet();
820
783
  */
821
784
  var Stream = class {
822
785
  constructor() {
823
- _classPrivateMethodInitSpec(this, _Stream_brand);
824
- _classPrivateFieldInitSpec(this, _buffer, []);
825
- _classPrivateFieldInitSpec(this, _listeners, []);
826
- _classPrivateFieldInitSpec(this, _alive, true);
827
- _classPrivateFieldInitSpec(this, _success, false);
828
- _classPrivateFieldInitSpec(this, _count, 0);
786
+ this.buffer = [];
787
+ this.listeners = [];
788
+ this.alive = true;
789
+ this.success = false;
790
+ this.count = 0;
791
+ }
792
+ flush(value, mode) {
793
+ for (let x = 0; x < this.count; x++) {
794
+ var _this$listeners$x;
795
+ (_this$listeners$x = this.listeners[x]) === null || _this$listeners$x === void 0 || _this$listeners$x[mode](value);
796
+ }
797
+ }
798
+ replay(listener) {
799
+ for (let x = 0, z = this.buffer.length; x < z; x++) {
800
+ const current = this.buffer[x];
801
+ if (!this.alive && x === z - 1) listener[this.success ? "return" : "throw"](current);
802
+ else listener.next(current);
803
+ }
829
804
  }
830
805
  on(listener) {
831
- let subscribed = _classPrivateFieldGet2(_alive, this);
806
+ let subscribed = this.alive;
832
807
  let temp = 0;
833
808
  if (subscribed) {
834
- for (; temp < _classPrivateFieldGet2(_count, this); temp++) if (!_classPrivateFieldGet2(_listeners, this)[temp]) break;
835
- if (temp === _classPrivateFieldGet2(_count, this)) {
836
- var _this$count;
837
- _classPrivateFieldSet2(_count, this, (_this$count = _classPrivateFieldGet2(_count, this), _this$count++, _this$count));
838
- }
839
- _classPrivateFieldGet2(_listeners, this)[temp] = listener;
809
+ for (; temp < this.count; temp++) if (!this.listeners[temp]) break;
810
+ if (temp === this.count) this.count++;
811
+ this.listeners[temp] = listener;
840
812
  }
841
- _assertClassBrand(_Stream_brand, this, _replay).call(this, listener);
813
+ this.replay(listener);
842
814
  return () => {
843
- if (_classPrivateFieldGet2(_alive, this) && subscribed) {
815
+ if (this.alive && subscribed) {
844
816
  subscribed = false;
845
- _classPrivateFieldGet2(_listeners, this)[temp] = void 0;
846
- while (_classPrivateFieldGet2(_count, this) > 0 && !_classPrivateFieldGet2(_listeners, this)[_classPrivateFieldGet2(_count, this) - 1]) {
847
- var _this$count3;
848
- _classPrivateFieldSet2(_count, this, (_this$count3 = _classPrivateFieldGet2(_count, this), _this$count3--, _this$count3));
849
- }
850
- _classPrivateFieldGet2(_listeners, this).length = _classPrivateFieldGet2(_count, this);
817
+ this.listeners[temp] = void 0;
818
+ while (this.count > 0 && !this.listeners[this.count - 1]) this.count--;
819
+ this.listeners.length = this.count;
851
820
  }
852
821
  };
853
822
  }
854
823
  next(value) {
855
- if (_classPrivateFieldGet2(_alive, this)) {
856
- _classPrivateFieldGet2(_buffer, this).push(value);
857
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "next");
824
+ if (this.alive) {
825
+ this.buffer.push(value);
826
+ this.flush(value, "next");
858
827
  }
859
828
  }
860
829
  throw(value) {
861
- if (_classPrivateFieldGet2(_alive, this)) {
862
- _classPrivateFieldGet2(_buffer, this).push(value);
863
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "throw");
864
- _classPrivateFieldSet2(_alive, this, false);
865
- _classPrivateFieldSet2(_success, this, false);
866
- _classPrivateFieldGet2(_listeners, this).length = 0;
830
+ if (this.alive) {
831
+ this.buffer.push(value);
832
+ this.flush(value, "throw");
833
+ this.alive = false;
834
+ this.success = false;
835
+ this.listeners.length = 0;
867
836
  }
868
837
  }
869
838
  return(value) {
870
- if (_classPrivateFieldGet2(_alive, this)) {
871
- _classPrivateFieldGet2(_buffer, this).push(value);
872
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "return");
873
- _classPrivateFieldSet2(_alive, this, false);
874
- _classPrivateFieldSet2(_success, this, true);
875
- _classPrivateFieldGet2(_listeners, this).length = 0;
839
+ if (this.alive) {
840
+ this.buffer.push(value);
841
+ this.flush(value, "return");
842
+ this.alive = false;
843
+ this.success = true;
844
+ this.listeners.length = 0;
876
845
  }
877
846
  }
878
847
  };
879
- function _flush(value, mode) {
880
- for (let x = 0; x < _classPrivateFieldGet2(_count, this); x++) {
881
- var _classPrivateFieldGet2$1;
882
- (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_listeners, this)[x]) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1[mode](value);
883
- }
884
- }
885
- function _replay(listener) {
886
- for (let x = 0, z = _classPrivateFieldGet2(_buffer, this).length; x < z; x++) {
887
- const current = _classPrivateFieldGet2(_buffer, this)[x];
888
- if (!_classPrivateFieldGet2(_alive, this) && x === z - 1) listener[_classPrivateFieldGet2(_success, this) ? "return" : "throw"](current);
889
- else listener.next(current);
890
- }
891
- }
892
848
  function isStream(value) {
893
849
  return value instanceof Stream;
894
850
  }
@@ -749,7 +749,13 @@ interface StreamListener<T> {
749
749
  * implementations in sync.
750
750
  */
751
751
  declare class Stream<T> {
752
- #private;
752
+ private buffer;
753
+ private listeners;
754
+ private alive;
755
+ private success;
756
+ private count;
757
+ private flush;
758
+ private replay;
753
759
  on(listener: StreamListener<T>): () => void;
754
760
  next(value: T): void;
755
761
  throw(value: unknown): void;
@@ -749,7 +749,13 @@ interface StreamListener<T> {
749
749
  * implementations in sync.
750
750
  */
751
751
  declare class Stream<T> {
752
- #private;
752
+ private buffer;
753
+ private listeners;
754
+ private alive;
755
+ private success;
756
+ private count;
757
+ private flush;
758
+ private replay;
753
759
  on(listener: StreamListener<T>): () => void;
754
760
  next(value: T): void;
755
761
  throw(value: unknown): void;
package/dist/dev/index.js CHANGED
@@ -768,44 +768,7 @@ const SPECIAL_REF_STRING = {
768
768
  [5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
769
769
  };
770
770
  //#endregion
771
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
772
- function _checkPrivateRedeclaration(e, t) {
773
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
774
- }
775
- //#endregion
776
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
777
- function _classPrivateMethodInitSpec(e, a) {
778
- _checkPrivateRedeclaration(e, a), a.add(e);
779
- }
780
- //#endregion
781
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
782
- function _classPrivateFieldInitSpec(e, t, a) {
783
- _checkPrivateRedeclaration(e, t), t.set(e, a);
784
- }
785
- //#endregion
786
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
787
- function _assertClassBrand(e, t, n) {
788
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
789
- throw new TypeError("Private element is not present on this object");
790
- }
791
- //#endregion
792
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
793
- function _classPrivateFieldGet2(s, a) {
794
- return s.get(_assertClassBrand(s, a));
795
- }
796
- //#endregion
797
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
798
- function _classPrivateFieldSet2(s, a, r) {
799
- return s.set(_assertClassBrand(s, a), r), r;
800
- }
801
- //#endregion
802
771
  //#region src/core/stream.ts
803
- var _buffer = /* @__PURE__ */ new WeakMap();
804
- var _listeners = /* @__PURE__ */ new WeakMap();
805
- var _alive = /* @__PURE__ */ new WeakMap();
806
- var _success = /* @__PURE__ */ new WeakMap();
807
- var _count = /* @__PURE__ */ new WeakMap();
808
- var _Stream_brand = /* @__PURE__ */ new WeakSet();
809
772
  /**
810
773
  * An internal class rather than a tagged POJO: identity is checked with
811
774
  * `instanceof`, which untrusted input cannot forge (the class is not exported).
@@ -819,75 +782,68 @@ var _Stream_brand = /* @__PURE__ */ new WeakSet();
819
782
  */
820
783
  var Stream = class {
821
784
  constructor() {
822
- _classPrivateMethodInitSpec(this, _Stream_brand);
823
- _classPrivateFieldInitSpec(this, _buffer, []);
824
- _classPrivateFieldInitSpec(this, _listeners, []);
825
- _classPrivateFieldInitSpec(this, _alive, true);
826
- _classPrivateFieldInitSpec(this, _success, false);
827
- _classPrivateFieldInitSpec(this, _count, 0);
785
+ this.buffer = [];
786
+ this.listeners = [];
787
+ this.alive = true;
788
+ this.success = false;
789
+ this.count = 0;
790
+ }
791
+ flush(value, mode) {
792
+ for (let x = 0; x < this.count; x++) {
793
+ var _this$listeners$x;
794
+ (_this$listeners$x = this.listeners[x]) === null || _this$listeners$x === void 0 || _this$listeners$x[mode](value);
795
+ }
796
+ }
797
+ replay(listener) {
798
+ for (let x = 0, z = this.buffer.length; x < z; x++) {
799
+ const current = this.buffer[x];
800
+ if (!this.alive && x === z - 1) listener[this.success ? "return" : "throw"](current);
801
+ else listener.next(current);
802
+ }
828
803
  }
829
804
  on(listener) {
830
- let subscribed = _classPrivateFieldGet2(_alive, this);
805
+ let subscribed = this.alive;
831
806
  let temp = 0;
832
807
  if (subscribed) {
833
- for (; temp < _classPrivateFieldGet2(_count, this); temp++) if (!_classPrivateFieldGet2(_listeners, this)[temp]) break;
834
- if (temp === _classPrivateFieldGet2(_count, this)) {
835
- var _this$count;
836
- _classPrivateFieldSet2(_count, this, (_this$count = _classPrivateFieldGet2(_count, this), _this$count++, _this$count));
837
- }
838
- _classPrivateFieldGet2(_listeners, this)[temp] = listener;
808
+ for (; temp < this.count; temp++) if (!this.listeners[temp]) break;
809
+ if (temp === this.count) this.count++;
810
+ this.listeners[temp] = listener;
839
811
  }
840
- _assertClassBrand(_Stream_brand, this, _replay).call(this, listener);
812
+ this.replay(listener);
841
813
  return () => {
842
- if (_classPrivateFieldGet2(_alive, this) && subscribed) {
814
+ if (this.alive && subscribed) {
843
815
  subscribed = false;
844
- _classPrivateFieldGet2(_listeners, this)[temp] = void 0;
845
- while (_classPrivateFieldGet2(_count, this) > 0 && !_classPrivateFieldGet2(_listeners, this)[_classPrivateFieldGet2(_count, this) - 1]) {
846
- var _this$count3;
847
- _classPrivateFieldSet2(_count, this, (_this$count3 = _classPrivateFieldGet2(_count, this), _this$count3--, _this$count3));
848
- }
849
- _classPrivateFieldGet2(_listeners, this).length = _classPrivateFieldGet2(_count, this);
816
+ this.listeners[temp] = void 0;
817
+ while (this.count > 0 && !this.listeners[this.count - 1]) this.count--;
818
+ this.listeners.length = this.count;
850
819
  }
851
820
  };
852
821
  }
853
822
  next(value) {
854
- if (_classPrivateFieldGet2(_alive, this)) {
855
- _classPrivateFieldGet2(_buffer, this).push(value);
856
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "next");
823
+ if (this.alive) {
824
+ this.buffer.push(value);
825
+ this.flush(value, "next");
857
826
  }
858
827
  }
859
828
  throw(value) {
860
- if (_classPrivateFieldGet2(_alive, this)) {
861
- _classPrivateFieldGet2(_buffer, this).push(value);
862
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "throw");
863
- _classPrivateFieldSet2(_alive, this, false);
864
- _classPrivateFieldSet2(_success, this, false);
865
- _classPrivateFieldGet2(_listeners, this).length = 0;
829
+ if (this.alive) {
830
+ this.buffer.push(value);
831
+ this.flush(value, "throw");
832
+ this.alive = false;
833
+ this.success = false;
834
+ this.listeners.length = 0;
866
835
  }
867
836
  }
868
837
  return(value) {
869
- if (_classPrivateFieldGet2(_alive, this)) {
870
- _classPrivateFieldGet2(_buffer, this).push(value);
871
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "return");
872
- _classPrivateFieldSet2(_alive, this, false);
873
- _classPrivateFieldSet2(_success, this, true);
874
- _classPrivateFieldGet2(_listeners, this).length = 0;
838
+ if (this.alive) {
839
+ this.buffer.push(value);
840
+ this.flush(value, "return");
841
+ this.alive = false;
842
+ this.success = true;
843
+ this.listeners.length = 0;
875
844
  }
876
845
  }
877
846
  };
878
- function _flush(value, mode) {
879
- for (let x = 0; x < _classPrivateFieldGet2(_count, this); x++) {
880
- var _classPrivateFieldGet2$1;
881
- (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_listeners, this)[x]) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1[mode](value);
882
- }
883
- }
884
- function _replay(listener) {
885
- for (let x = 0, z = _classPrivateFieldGet2(_buffer, this).length; x < z; x++) {
886
- const current = _classPrivateFieldGet2(_buffer, this)[x];
887
- if (!_classPrivateFieldGet2(_alive, this) && x === z - 1) listener[_classPrivateFieldGet2(_success, this) ? "return" : "throw"](current);
888
- else listener.next(current);
889
- }
890
- }
891
847
  function isStream(value) {
892
848
  return value instanceof Stream;
893
849
  }
package/dist/index.cjs CHANGED
@@ -762,44 +762,7 @@ const SPECIAL_REF_STRING = {
762
762
  [5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
763
763
  };
764
764
  //#endregion
765
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
766
- function _checkPrivateRedeclaration(e, t) {
767
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
768
- }
769
- //#endregion
770
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
771
- function _classPrivateMethodInitSpec(e, a) {
772
- _checkPrivateRedeclaration(e, a), a.add(e);
773
- }
774
- //#endregion
775
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
776
- function _classPrivateFieldInitSpec(e, t, a) {
777
- _checkPrivateRedeclaration(e, t), t.set(e, a);
778
- }
779
- //#endregion
780
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
781
- function _assertClassBrand(e, t, n) {
782
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
783
- throw new TypeError("Private element is not present on this object");
784
- }
785
- //#endregion
786
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
787
- function _classPrivateFieldGet2(s, a) {
788
- return s.get(_assertClassBrand(s, a));
789
- }
790
- //#endregion
791
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
792
- function _classPrivateFieldSet2(s, a, r) {
793
- return s.set(_assertClassBrand(s, a), r), r;
794
- }
795
- //#endregion
796
765
  //#region src/core/stream.ts
797
- var _buffer = /* @__PURE__ */ new WeakMap();
798
- var _listeners = /* @__PURE__ */ new WeakMap();
799
- var _alive = /* @__PURE__ */ new WeakMap();
800
- var _success = /* @__PURE__ */ new WeakMap();
801
- var _count = /* @__PURE__ */ new WeakMap();
802
- var _Stream_brand = /* @__PURE__ */ new WeakSet();
803
766
  /**
804
767
  * An internal class rather than a tagged POJO: identity is checked with
805
768
  * `instanceof`, which untrusted input cannot forge (the class is not exported).
@@ -813,75 +776,68 @@ var _Stream_brand = /* @__PURE__ */ new WeakSet();
813
776
  */
814
777
  var Stream = class {
815
778
  constructor() {
816
- _classPrivateMethodInitSpec(this, _Stream_brand);
817
- _classPrivateFieldInitSpec(this, _buffer, []);
818
- _classPrivateFieldInitSpec(this, _listeners, []);
819
- _classPrivateFieldInitSpec(this, _alive, true);
820
- _classPrivateFieldInitSpec(this, _success, false);
821
- _classPrivateFieldInitSpec(this, _count, 0);
779
+ this.buffer = [];
780
+ this.listeners = [];
781
+ this.alive = true;
782
+ this.success = false;
783
+ this.count = 0;
784
+ }
785
+ flush(value, mode) {
786
+ for (let x = 0; x < this.count; x++) {
787
+ var _this$listeners$x;
788
+ (_this$listeners$x = this.listeners[x]) === null || _this$listeners$x === void 0 || _this$listeners$x[mode](value);
789
+ }
790
+ }
791
+ replay(listener) {
792
+ for (let x = 0, z = this.buffer.length; x < z; x++) {
793
+ const current = this.buffer[x];
794
+ if (!this.alive && x === z - 1) listener[this.success ? "return" : "throw"](current);
795
+ else listener.next(current);
796
+ }
822
797
  }
823
798
  on(listener) {
824
- let subscribed = _classPrivateFieldGet2(_alive, this);
799
+ let subscribed = this.alive;
825
800
  let temp = 0;
826
801
  if (subscribed) {
827
- for (; temp < _classPrivateFieldGet2(_count, this); temp++) if (!_classPrivateFieldGet2(_listeners, this)[temp]) break;
828
- if (temp === _classPrivateFieldGet2(_count, this)) {
829
- var _this$count;
830
- _classPrivateFieldSet2(_count, this, (_this$count = _classPrivateFieldGet2(_count, this), _this$count++, _this$count));
831
- }
832
- _classPrivateFieldGet2(_listeners, this)[temp] = listener;
802
+ for (; temp < this.count; temp++) if (!this.listeners[temp]) break;
803
+ if (temp === this.count) this.count++;
804
+ this.listeners[temp] = listener;
833
805
  }
834
- _assertClassBrand(_Stream_brand, this, _replay).call(this, listener);
806
+ this.replay(listener);
835
807
  return () => {
836
- if (_classPrivateFieldGet2(_alive, this) && subscribed) {
808
+ if (this.alive && subscribed) {
837
809
  subscribed = false;
838
- _classPrivateFieldGet2(_listeners, this)[temp] = void 0;
839
- while (_classPrivateFieldGet2(_count, this) > 0 && !_classPrivateFieldGet2(_listeners, this)[_classPrivateFieldGet2(_count, this) - 1]) {
840
- var _this$count3;
841
- _classPrivateFieldSet2(_count, this, (_this$count3 = _classPrivateFieldGet2(_count, this), _this$count3--, _this$count3));
842
- }
843
- _classPrivateFieldGet2(_listeners, this).length = _classPrivateFieldGet2(_count, this);
810
+ this.listeners[temp] = void 0;
811
+ while (this.count > 0 && !this.listeners[this.count - 1]) this.count--;
812
+ this.listeners.length = this.count;
844
813
  }
845
814
  };
846
815
  }
847
816
  next(value) {
848
- if (_classPrivateFieldGet2(_alive, this)) {
849
- _classPrivateFieldGet2(_buffer, this).push(value);
850
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "next");
817
+ if (this.alive) {
818
+ this.buffer.push(value);
819
+ this.flush(value, "next");
851
820
  }
852
821
  }
853
822
  throw(value) {
854
- if (_classPrivateFieldGet2(_alive, this)) {
855
- _classPrivateFieldGet2(_buffer, this).push(value);
856
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "throw");
857
- _classPrivateFieldSet2(_alive, this, false);
858
- _classPrivateFieldSet2(_success, this, false);
859
- _classPrivateFieldGet2(_listeners, this).length = 0;
823
+ if (this.alive) {
824
+ this.buffer.push(value);
825
+ this.flush(value, "throw");
826
+ this.alive = false;
827
+ this.success = false;
828
+ this.listeners.length = 0;
860
829
  }
861
830
  }
862
831
  return(value) {
863
- if (_classPrivateFieldGet2(_alive, this)) {
864
- _classPrivateFieldGet2(_buffer, this).push(value);
865
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "return");
866
- _classPrivateFieldSet2(_alive, this, false);
867
- _classPrivateFieldSet2(_success, this, true);
868
- _classPrivateFieldGet2(_listeners, this).length = 0;
832
+ if (this.alive) {
833
+ this.buffer.push(value);
834
+ this.flush(value, "return");
835
+ this.alive = false;
836
+ this.success = true;
837
+ this.listeners.length = 0;
869
838
  }
870
839
  }
871
840
  };
872
- function _flush(value, mode) {
873
- for (let x = 0; x < _classPrivateFieldGet2(_count, this); x++) {
874
- var _classPrivateFieldGet2$1;
875
- (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_listeners, this)[x]) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1[mode](value);
876
- }
877
- }
878
- function _replay(listener) {
879
- for (let x = 0, z = _classPrivateFieldGet2(_buffer, this).length; x < z; x++) {
880
- const current = _classPrivateFieldGet2(_buffer, this)[x];
881
- if (!_classPrivateFieldGet2(_alive, this) && x === z - 1) listener[_classPrivateFieldGet2(_success, this) ? "return" : "throw"](current);
882
- else listener.next(current);
883
- }
884
- }
885
841
  function isStream(value) {
886
842
  return value instanceof Stream;
887
843
  }
package/dist/index.d.cts CHANGED
@@ -749,7 +749,13 @@ interface StreamListener<T> {
749
749
  * implementations in sync.
750
750
  */
751
751
  declare class Stream<T> {
752
- #private;
752
+ private buffer;
753
+ private listeners;
754
+ private alive;
755
+ private success;
756
+ private count;
757
+ private flush;
758
+ private replay;
753
759
  on(listener: StreamListener<T>): () => void;
754
760
  next(value: T): void;
755
761
  throw(value: unknown): void;
package/dist/index.d.ts CHANGED
@@ -749,7 +749,13 @@ interface StreamListener<T> {
749
749
  * implementations in sync.
750
750
  */
751
751
  declare class Stream<T> {
752
- #private;
752
+ private buffer;
753
+ private listeners;
754
+ private alive;
755
+ private success;
756
+ private count;
757
+ private flush;
758
+ private replay;
753
759
  on(listener: StreamListener<T>): () => void;
754
760
  next(value: T): void;
755
761
  throw(value: unknown): void;
package/dist/index.js CHANGED
@@ -761,44 +761,7 @@ const SPECIAL_REF_STRING = {
761
761
  [5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
762
762
  };
763
763
  //#endregion
764
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
765
- function _checkPrivateRedeclaration(e, t) {
766
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
767
- }
768
- //#endregion
769
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
770
- function _classPrivateMethodInitSpec(e, a) {
771
- _checkPrivateRedeclaration(e, a), a.add(e);
772
- }
773
- //#endregion
774
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
775
- function _classPrivateFieldInitSpec(e, t, a) {
776
- _checkPrivateRedeclaration(e, t), t.set(e, a);
777
- }
778
- //#endregion
779
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
780
- function _assertClassBrand(e, t, n) {
781
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
782
- throw new TypeError("Private element is not present on this object");
783
- }
784
- //#endregion
785
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
786
- function _classPrivateFieldGet2(s, a) {
787
- return s.get(_assertClassBrand(s, a));
788
- }
789
- //#endregion
790
- //#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
791
- function _classPrivateFieldSet2(s, a, r) {
792
- return s.set(_assertClassBrand(s, a), r), r;
793
- }
794
- //#endregion
795
764
  //#region src/core/stream.ts
796
- var _buffer = /* @__PURE__ */ new WeakMap();
797
- var _listeners = /* @__PURE__ */ new WeakMap();
798
- var _alive = /* @__PURE__ */ new WeakMap();
799
- var _success = /* @__PURE__ */ new WeakMap();
800
- var _count = /* @__PURE__ */ new WeakMap();
801
- var _Stream_brand = /* @__PURE__ */ new WeakSet();
802
765
  /**
803
766
  * An internal class rather than a tagged POJO: identity is checked with
804
767
  * `instanceof`, which untrusted input cannot forge (the class is not exported).
@@ -812,75 +775,68 @@ var _Stream_brand = /* @__PURE__ */ new WeakSet();
812
775
  */
813
776
  var Stream = class {
814
777
  constructor() {
815
- _classPrivateMethodInitSpec(this, _Stream_brand);
816
- _classPrivateFieldInitSpec(this, _buffer, []);
817
- _classPrivateFieldInitSpec(this, _listeners, []);
818
- _classPrivateFieldInitSpec(this, _alive, true);
819
- _classPrivateFieldInitSpec(this, _success, false);
820
- _classPrivateFieldInitSpec(this, _count, 0);
778
+ this.buffer = [];
779
+ this.listeners = [];
780
+ this.alive = true;
781
+ this.success = false;
782
+ this.count = 0;
783
+ }
784
+ flush(value, mode) {
785
+ for (let x = 0; x < this.count; x++) {
786
+ var _this$listeners$x;
787
+ (_this$listeners$x = this.listeners[x]) === null || _this$listeners$x === void 0 || _this$listeners$x[mode](value);
788
+ }
789
+ }
790
+ replay(listener) {
791
+ for (let x = 0, z = this.buffer.length; x < z; x++) {
792
+ const current = this.buffer[x];
793
+ if (!this.alive && x === z - 1) listener[this.success ? "return" : "throw"](current);
794
+ else listener.next(current);
795
+ }
821
796
  }
822
797
  on(listener) {
823
- let subscribed = _classPrivateFieldGet2(_alive, this);
798
+ let subscribed = this.alive;
824
799
  let temp = 0;
825
800
  if (subscribed) {
826
- for (; temp < _classPrivateFieldGet2(_count, this); temp++) if (!_classPrivateFieldGet2(_listeners, this)[temp]) break;
827
- if (temp === _classPrivateFieldGet2(_count, this)) {
828
- var _this$count;
829
- _classPrivateFieldSet2(_count, this, (_this$count = _classPrivateFieldGet2(_count, this), _this$count++, _this$count));
830
- }
831
- _classPrivateFieldGet2(_listeners, this)[temp] = listener;
801
+ for (; temp < this.count; temp++) if (!this.listeners[temp]) break;
802
+ if (temp === this.count) this.count++;
803
+ this.listeners[temp] = listener;
832
804
  }
833
- _assertClassBrand(_Stream_brand, this, _replay).call(this, listener);
805
+ this.replay(listener);
834
806
  return () => {
835
- if (_classPrivateFieldGet2(_alive, this) && subscribed) {
807
+ if (this.alive && subscribed) {
836
808
  subscribed = false;
837
- _classPrivateFieldGet2(_listeners, this)[temp] = void 0;
838
- while (_classPrivateFieldGet2(_count, this) > 0 && !_classPrivateFieldGet2(_listeners, this)[_classPrivateFieldGet2(_count, this) - 1]) {
839
- var _this$count3;
840
- _classPrivateFieldSet2(_count, this, (_this$count3 = _classPrivateFieldGet2(_count, this), _this$count3--, _this$count3));
841
- }
842
- _classPrivateFieldGet2(_listeners, this).length = _classPrivateFieldGet2(_count, this);
809
+ this.listeners[temp] = void 0;
810
+ while (this.count > 0 && !this.listeners[this.count - 1]) this.count--;
811
+ this.listeners.length = this.count;
843
812
  }
844
813
  };
845
814
  }
846
815
  next(value) {
847
- if (_classPrivateFieldGet2(_alive, this)) {
848
- _classPrivateFieldGet2(_buffer, this).push(value);
849
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "next");
816
+ if (this.alive) {
817
+ this.buffer.push(value);
818
+ this.flush(value, "next");
850
819
  }
851
820
  }
852
821
  throw(value) {
853
- if (_classPrivateFieldGet2(_alive, this)) {
854
- _classPrivateFieldGet2(_buffer, this).push(value);
855
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "throw");
856
- _classPrivateFieldSet2(_alive, this, false);
857
- _classPrivateFieldSet2(_success, this, false);
858
- _classPrivateFieldGet2(_listeners, this).length = 0;
822
+ if (this.alive) {
823
+ this.buffer.push(value);
824
+ this.flush(value, "throw");
825
+ this.alive = false;
826
+ this.success = false;
827
+ this.listeners.length = 0;
859
828
  }
860
829
  }
861
830
  return(value) {
862
- if (_classPrivateFieldGet2(_alive, this)) {
863
- _classPrivateFieldGet2(_buffer, this).push(value);
864
- _assertClassBrand(_Stream_brand, this, _flush).call(this, value, "return");
865
- _classPrivateFieldSet2(_alive, this, false);
866
- _classPrivateFieldSet2(_success, this, true);
867
- _classPrivateFieldGet2(_listeners, this).length = 0;
831
+ if (this.alive) {
832
+ this.buffer.push(value);
833
+ this.flush(value, "return");
834
+ this.alive = false;
835
+ this.success = true;
836
+ this.listeners.length = 0;
868
837
  }
869
838
  }
870
839
  };
871
- function _flush(value, mode) {
872
- for (let x = 0; x < _classPrivateFieldGet2(_count, this); x++) {
873
- var _classPrivateFieldGet2$1;
874
- (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_listeners, this)[x]) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1[mode](value);
875
- }
876
- }
877
- function _replay(listener) {
878
- for (let x = 0, z = _classPrivateFieldGet2(_buffer, this).length; x < z; x++) {
879
- const current = _classPrivateFieldGet2(_buffer, this)[x];
880
- if (!_classPrivateFieldGet2(_alive, this) && x === z - 1) listener[_classPrivateFieldGet2(_success, this) ? "return" : "throw"](current);
881
- else listener.next(current);
882
- }
883
- }
884
840
  function isStream(value) {
885
841
  return value instanceof Stream;
886
842
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "seroval",
3
3
  "type": "module",
4
- "version": "1.6.8",
4
+ "version": "1.6.9",
5
5
  "files": [
6
6
  "dist"
7
7
  ],