@rjsf/utils 6.7.1 → 6.8.0

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/utils.esm.js CHANGED
@@ -3433,12 +3433,18 @@ function hashString(string) {
3433
3433
  return hash.toString(16);
3434
3434
  }
3435
3435
  function sortedJSONStringify(object) {
3436
- const allKeys = /* @__PURE__ */ new Set();
3437
- JSON.stringify(object, (key, value) => {
3438
- allKeys.add(key);
3439
- return value;
3440
- });
3441
- return JSON.stringify(object, Array.from(allKeys).sort());
3436
+ function shouldIncludeValue(value) {
3437
+ return value !== void 0 && typeof value !== "function" && typeof value !== "symbol";
3438
+ }
3439
+ if (Array.isArray(object)) {
3440
+ return `[${object.map((x) => x === void 0 ? "undefined" : sortedJSONStringify(x)).join(",")}]`;
3441
+ }
3442
+ if (object === null || typeof object !== "object") {
3443
+ return JSON.stringify(typeof object === "function" ? null : object);
3444
+ }
3445
+ const record = object;
3446
+ const sortedValues = Object.keys(record).sort().filter((key) => shouldIncludeValue(record[key])).map((key) => `${JSON.stringify(key)}:${sortedJSONStringify(record[key])}`);
3447
+ return `{${sortedValues.join(",")}}`;
3442
3448
  }
3443
3449
  function hashObject(object) {
3444
3450
  return hashString(sortedJSONStringify(object));