seroval 0.10.2 → 0.10.3
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/cjs/development/index.cjs +32 -4
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +2 -2
- package/dist/esm/development/index.mjs +32 -4
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +2 -2
- package/dist/types/core/Serializer.d.ts +5 -0
- package/package.json +2 -2
- package/src/core/Serializer.ts +39 -6
|
@@ -5004,28 +5004,56 @@ var Serializer = class {
|
|
|
5004
5004
|
constructor(options) {
|
|
5005
5005
|
this.options = options;
|
|
5006
5006
|
__publicField(this, "alive", true);
|
|
5007
|
+
__publicField(this, "flushed", false);
|
|
5008
|
+
__publicField(this, "done", false);
|
|
5009
|
+
__publicField(this, "pending", 0);
|
|
5007
5010
|
__publicField(this, "cleanups", []);
|
|
5008
5011
|
__publicField(this, "refs", /* @__PURE__ */ new Map());
|
|
5009
5012
|
}
|
|
5010
5013
|
write(key, value) {
|
|
5011
|
-
if (this.alive) {
|
|
5014
|
+
if (this.alive && !this.flushed) {
|
|
5015
|
+
this.pending++;
|
|
5012
5016
|
this.cleanups.push(crossSerializeStream(value, {
|
|
5013
5017
|
scopeId: this.options.scopeId,
|
|
5014
5018
|
refs: this.refs,
|
|
5015
5019
|
disabledFeatures: this.options.disabledFeatures,
|
|
5016
5020
|
onSerialize: (data, initial) => {
|
|
5017
|
-
this.
|
|
5018
|
-
|
|
5019
|
-
|
|
5021
|
+
if (this.alive) {
|
|
5022
|
+
this.options.onData(
|
|
5023
|
+
initial ? this.options.globalIdentifier + '["' + serializeString(key) + '"]=' + data : data
|
|
5024
|
+
);
|
|
5025
|
+
}
|
|
5026
|
+
},
|
|
5027
|
+
onDone: () => {
|
|
5028
|
+
if (this.alive) {
|
|
5029
|
+
this.pending--;
|
|
5030
|
+
if (this.pending <= 0 && this.flushed && !this.done && this.options.onDone) {
|
|
5031
|
+
this.options.onDone();
|
|
5032
|
+
this.done = true;
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
5020
5035
|
}
|
|
5021
5036
|
}));
|
|
5022
5037
|
}
|
|
5023
5038
|
}
|
|
5039
|
+
flush() {
|
|
5040
|
+
if (this.alive) {
|
|
5041
|
+
this.flushed = true;
|
|
5042
|
+
if (this.pending <= 0 && !this.done && this.options.onDone) {
|
|
5043
|
+
this.options.onDone();
|
|
5044
|
+
this.done = true;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5024
5048
|
close() {
|
|
5025
5049
|
if (this.alive) {
|
|
5026
5050
|
for (let i = 0, len = this.cleanups.length; i < len; i++) {
|
|
5027
5051
|
this.cleanups[i]();
|
|
5028
5052
|
}
|
|
5053
|
+
if (!this.done && this.options.onDone) {
|
|
5054
|
+
this.options.onDone();
|
|
5055
|
+
this.done = true;
|
|
5056
|
+
}
|
|
5029
5057
|
this.alive = false;
|
|
5030
5058
|
}
|
|
5031
5059
|
}
|