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.
- package/dist/dev/index.cjs +42 -86
- package/dist/dev/index.d.cts +7 -1
- package/dist/dev/index.d.ts +7 -1
- package/dist/dev/index.js +42 -86
- package/dist/index.cjs +42 -86
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +42 -86
- package/package.json +1 -1
package/dist/dev/index.cjs
CHANGED
|
@@ -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
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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 =
|
|
806
|
+
let subscribed = this.alive;
|
|
832
807
|
let temp = 0;
|
|
833
808
|
if (subscribed) {
|
|
834
|
-
for (; temp <
|
|
835
|
-
if (temp ===
|
|
836
|
-
|
|
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
|
-
|
|
813
|
+
this.replay(listener);
|
|
842
814
|
return () => {
|
|
843
|
-
if (
|
|
815
|
+
if (this.alive && subscribed) {
|
|
844
816
|
subscribed = false;
|
|
845
|
-
|
|
846
|
-
while (
|
|
847
|
-
|
|
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 (
|
|
856
|
-
|
|
857
|
-
|
|
824
|
+
if (this.alive) {
|
|
825
|
+
this.buffer.push(value);
|
|
826
|
+
this.flush(value, "next");
|
|
858
827
|
}
|
|
859
828
|
}
|
|
860
829
|
throw(value) {
|
|
861
|
-
if (
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
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 (
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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
|
}
|
package/dist/dev/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
|
-
|
|
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.d.ts
CHANGED
|
@@ -749,7 +749,13 @@ interface StreamListener<T> {
|
|
|
749
749
|
* implementations in sync.
|
|
750
750
|
*/
|
|
751
751
|
declare class Stream<T> {
|
|
752
|
-
|
|
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
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
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 =
|
|
805
|
+
let subscribed = this.alive;
|
|
831
806
|
let temp = 0;
|
|
832
807
|
if (subscribed) {
|
|
833
|
-
for (; temp <
|
|
834
|
-
if (temp ===
|
|
835
|
-
|
|
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
|
-
|
|
812
|
+
this.replay(listener);
|
|
841
813
|
return () => {
|
|
842
|
-
if (
|
|
814
|
+
if (this.alive && subscribed) {
|
|
843
815
|
subscribed = false;
|
|
844
|
-
|
|
845
|
-
while (
|
|
846
|
-
|
|
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 (
|
|
855
|
-
|
|
856
|
-
|
|
823
|
+
if (this.alive) {
|
|
824
|
+
this.buffer.push(value);
|
|
825
|
+
this.flush(value, "next");
|
|
857
826
|
}
|
|
858
827
|
}
|
|
859
828
|
throw(value) {
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
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 (
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
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
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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 =
|
|
799
|
+
let subscribed = this.alive;
|
|
825
800
|
let temp = 0;
|
|
826
801
|
if (subscribed) {
|
|
827
|
-
for (; temp <
|
|
828
|
-
if (temp ===
|
|
829
|
-
|
|
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
|
-
|
|
806
|
+
this.replay(listener);
|
|
835
807
|
return () => {
|
|
836
|
-
if (
|
|
808
|
+
if (this.alive && subscribed) {
|
|
837
809
|
subscribed = false;
|
|
838
|
-
|
|
839
|
-
while (
|
|
840
|
-
|
|
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 (
|
|
849
|
-
|
|
850
|
-
|
|
817
|
+
if (this.alive) {
|
|
818
|
+
this.buffer.push(value);
|
|
819
|
+
this.flush(value, "next");
|
|
851
820
|
}
|
|
852
821
|
}
|
|
853
822
|
throw(value) {
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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 (
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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 =
|
|
798
|
+
let subscribed = this.alive;
|
|
824
799
|
let temp = 0;
|
|
825
800
|
if (subscribed) {
|
|
826
|
-
for (; temp <
|
|
827
|
-
if (temp ===
|
|
828
|
-
|
|
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
|
-
|
|
805
|
+
this.replay(listener);
|
|
834
806
|
return () => {
|
|
835
|
-
if (
|
|
807
|
+
if (this.alive && subscribed) {
|
|
836
808
|
subscribed = false;
|
|
837
|
-
|
|
838
|
-
while (
|
|
839
|
-
|
|
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 (
|
|
848
|
-
|
|
849
|
-
|
|
816
|
+
if (this.alive) {
|
|
817
|
+
this.buffer.push(value);
|
|
818
|
+
this.flush(value, "next");
|
|
850
819
|
}
|
|
851
820
|
}
|
|
852
821
|
throw(value) {
|
|
853
|
-
if (
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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 (
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
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
|
}
|