@capture.dev/fast-json-patch 3.2.1 → 3.2.2

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/index.cjs CHANGED
@@ -702,21 +702,42 @@ function _generate(mirror, obj, patches, path, invertible) {
702
702
  if (hasOwnProperty(obj, key) && !(obj[key] === void 0 && oldVal !== void 0 && Array.isArray(obj) === false)) {
703
703
  var newVal = obj[key];
704
704
  if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
705
- _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key), invertible);
705
+ _generate(
706
+ oldVal,
707
+ newVal,
708
+ patches,
709
+ path + "/" + escapePathComponent(key),
710
+ invertible
711
+ );
706
712
  } else {
707
713
  if (oldVal !== newVal) {
708
714
  changed = true;
709
715
  if (invertible) {
710
- patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
716
+ patches.push({
717
+ op: "test",
718
+ path: path + "/" + escapePathComponent(key),
719
+ value: _deepClone(oldVal)
720
+ });
711
721
  }
712
- patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: _deepClone(newVal) });
722
+ patches.push({
723
+ op: "replace",
724
+ path: path + "/" + escapePathComponent(key),
725
+ value: _deepClone(newVal)
726
+ });
713
727
  }
714
728
  }
715
729
  } else if (Array.isArray(mirror) === Array.isArray(obj)) {
716
730
  if (invertible) {
717
- patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
731
+ patches.push({
732
+ op: "test",
733
+ path: path + "/" + escapePathComponent(key),
734
+ value: _deepClone(oldVal)
735
+ });
718
736
  }
719
- patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
737
+ patches.push({
738
+ op: "remove",
739
+ path: path + "/" + escapePathComponent(key)
740
+ });
720
741
  deleted = true;
721
742
  } else {
722
743
  if (invertible) {
@@ -732,7 +753,12 @@ function _generate(mirror, obj, patches, path, invertible) {
732
753
  for (var t = 0; t < newKeys.length; t++) {
733
754
  var key = newKeys[t];
734
755
  if (!hasOwnProperty(mirror, key) && obj[key] !== void 0) {
735
- patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: _deepClone(obj[key]) });
756
+ patches.push({
757
+ op: "add",
758
+ path: path + "/" + escapePathComponent(key),
759
+ value: _deepClone(obj[key]),
760
+ index: t
761
+ });
736
762
  }
737
763
  }
738
764
  }
package/dist/index.js CHANGED
@@ -663,21 +663,42 @@ function _generate(mirror, obj, patches, path, invertible) {
663
663
  if (hasOwnProperty(obj, key) && !(obj[key] === void 0 && oldVal !== void 0 && Array.isArray(obj) === false)) {
664
664
  var newVal = obj[key];
665
665
  if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
666
- _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key), invertible);
666
+ _generate(
667
+ oldVal,
668
+ newVal,
669
+ patches,
670
+ path + "/" + escapePathComponent(key),
671
+ invertible
672
+ );
667
673
  } else {
668
674
  if (oldVal !== newVal) {
669
675
  changed = true;
670
676
  if (invertible) {
671
- patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
677
+ patches.push({
678
+ op: "test",
679
+ path: path + "/" + escapePathComponent(key),
680
+ value: _deepClone(oldVal)
681
+ });
672
682
  }
673
- patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: _deepClone(newVal) });
683
+ patches.push({
684
+ op: "replace",
685
+ path: path + "/" + escapePathComponent(key),
686
+ value: _deepClone(newVal)
687
+ });
674
688
  }
675
689
  }
676
690
  } else if (Array.isArray(mirror) === Array.isArray(obj)) {
677
691
  if (invertible) {
678
- patches.push({ op: "test", path: path + "/" + escapePathComponent(key), value: _deepClone(oldVal) });
692
+ patches.push({
693
+ op: "test",
694
+ path: path + "/" + escapePathComponent(key),
695
+ value: _deepClone(oldVal)
696
+ });
679
697
  }
680
- patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
698
+ patches.push({
699
+ op: "remove",
700
+ path: path + "/" + escapePathComponent(key)
701
+ });
681
702
  deleted = true;
682
703
  } else {
683
704
  if (invertible) {
@@ -693,7 +714,12 @@ function _generate(mirror, obj, patches, path, invertible) {
693
714
  for (var t = 0; t < newKeys.length; t++) {
694
715
  var key = newKeys[t];
695
716
  if (!hasOwnProperty(mirror, key) && obj[key] !== void 0) {
696
- patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: _deepClone(obj[key]) });
717
+ patches.push({
718
+ op: "add",
719
+ path: path + "/" + escapePathComponent(key),
720
+ value: _deepClone(obj[key]),
721
+ index: t
722
+ });
697
723
  }
698
724
  }
699
725
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capture.dev/fast-json-patch",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Fast implementation of JSON-Patch (RFC-6902) with duplex (observe changes) capabilities",
@@ -53,12 +53,15 @@
53
53
  "saucelabs": "^2.1.9",
54
54
  "selenium-webdriver": "^4.0.0-alpha.4",
55
55
  "tsup": "^8.5.1",
56
- "typescript": "~5.9.3"
56
+ "typescript": "~5.9.3",
57
+ "vitest": "^4.0.17"
57
58
  },
58
59
  "scripts": {
59
60
  "build": "tsup",
60
61
  "watch": "tsup --watch",
61
- "test": "npm run tsc && npm run test-core && npm run test-duplex && npm run test-commonjs && npm run test-webpack-import && npm run test-typings",
62
+ "test": "vitest run",
63
+ "test:watch": "vitest",
64
+ "test:legacy": "npm run tsc && npm run test-core && npm run test-duplex && npm run test-commonjs && npm run test-webpack-import && npm run test-typings",
62
65
  "test-sauce": "npm run build && node test/Sauce/Runner.js",
63
66
  "test-commonjs": "jasmine test/spec/commonjs/requireSpec.js",
64
67
  "test-typings": "tsc test/spec/typings/typingsSpec.ts",