seroval 1.0.8 → 1.1.1

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.
@@ -2164,7 +2164,7 @@ var BaseSerializerContext = class {
2164
2164
  createFunction(parameters, body) {
2165
2165
  if (this.features & 2 /* ArrowFunction */) {
2166
2166
  const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
2167
- return joined + "=>" + body;
2167
+ return joined + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
2168
2168
  }
2169
2169
  return "function(" + parameters.join(",") + "){return " + body + "}";
2170
2170
  }
@@ -2903,9 +2903,12 @@ var CrossSerializerContext = class extends BaseSerializerContext {
2903
2903
  const patches = this.resolvePatches();
2904
2904
  const ref = this.getRefParam(id);
2905
2905
  const params = this.scopeId == null ? "" : GLOBAL_CONTEXT_REFERENCES;
2906
- const body = patches ? result + "," + patches + ref : result;
2906
+ const body = patches ? "(" + result + "," + patches + ref + ")" : result;
2907
2907
  if (params === "") {
2908
- return patches ? "(" + body + ")" : body;
2908
+ if (tree.t === 10 /* Object */ && !patches) {
2909
+ return "(" + body + ")";
2910
+ }
2911
+ return body;
2909
2912
  }
2910
2913
  const args = this.scopeId == null ? "()" : "(" + GLOBAL_CONTEXT_REFERENCES + '["' + serializeString(this.scopeId) + '"])';
2911
2914
  return "(" + this.createFunction([params], body) + ")" + args;
@@ -3651,8 +3654,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3651
3654
  if (!result.startsWith(index + "=")) {
3652
3655
  body = index + "=" + body;
3653
3656
  }
3657
+ body = "(" + body + ")";
3654
3658
  }
3655
- return "(" + this.createFunction(this.vars, "(" + body + ")") + ")()";
3659
+ return "(" + this.createFunction(this.vars, body) + ")()";
3656
3660
  }
3657
3661
  if (tree.t === 10 /* Object */) {
3658
3662
  return "(" + result + ")";