@arcanejs/diff 0.4.0 → 0.5.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.
@@ -5,7 +5,7 @@ var diffJson = (a, b) => {
5
5
  return { type: "match" };
6
6
  }
7
7
  if (!jsonTypeMatches(a, b)) {
8
- throw new Error("Types don't match, unable to diff");
8
+ return { type: "value", after: b };
9
9
  }
10
10
  if (Array.isArray(a) && Array.isArray(b)) {
11
11
  if (a.length === b.length) {
@@ -37,10 +37,10 @@ var diffJson = (a, b) => {
37
37
  }
38
38
  }
39
39
  if (a === null || b === null) {
40
- return { type: "value", before: a, after: b };
40
+ return { type: "value", after: b };
41
41
  }
42
42
  if (Array.isArray(a) || Array.isArray(b)) {
43
- return { type: "value", before: a, after: b };
43
+ return { type: "value", after: b };
44
44
  }
45
45
  if (typeof a === "object" && typeof b === "object") {
46
46
  const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
@@ -73,7 +73,7 @@ var diffJson = (a, b) => {
73
73
  return { type: "match" };
74
74
  }
75
75
  }
76
- return { type: "value", before: a, after: b };
76
+ return { type: "value", after: b };
77
77
  };
78
78
 
79
79
  export {
@@ -5,7 +5,7 @@ var diffJson = (a, b) => {
5
5
  return { type: "match" };
6
6
  }
7
7
  if (!jsonTypeMatches(a, b)) {
8
- throw new Error("Types don't match, unable to diff");
8
+ return { type: "value", after: b };
9
9
  }
10
10
  if (Array.isArray(a) && Array.isArray(b)) {
11
11
  if (a.length === b.length) {
@@ -37,10 +37,10 @@ var diffJson = (a, b) => {
37
37
  }
38
38
  }
39
39
  if (a === null || b === null) {
40
- return { type: "value", before: a, after: b };
40
+ return { type: "value", after: b };
41
41
  }
42
42
  if (Array.isArray(a) || Array.isArray(b)) {
43
- return { type: "value", before: a, after: b };
43
+ return { type: "value", after: b };
44
44
  }
45
45
  if (typeof a === "object" && typeof b === "object") {
46
46
  const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
@@ -73,7 +73,7 @@ var diffJson = (a, b) => {
73
73
  return { type: "match" };
74
74
  }
75
75
  }
76
- return { type: "value", before: a, after: b };
76
+ return { type: "value", after: b };
77
77
  };
78
78
 
79
79
 
package/dist/diff.d.mts CHANGED
@@ -7,7 +7,6 @@ type JSONValue = JSONPrimitive | JSONObject | JSONArray;
7
7
  type PossibleRecursiveDiff<V extends JSONValue | undefined> = V extends JSONValue ? NestedDiff<V> : never;
8
8
  type NestedDiff<V extends JSONValue> = (V extends JSONPrimitive ? {
9
9
  type: 'value';
10
- before: V;
11
10
  after: V;
12
11
  } : never) | (V extends JSONArray ? {
13
12
  type: 'splice';
package/dist/diff.d.ts CHANGED
@@ -7,7 +7,6 @@ type JSONValue = JSONPrimitive | JSONObject | JSONArray;
7
7
  type PossibleRecursiveDiff<V extends JSONValue | undefined> = V extends JSONValue ? NestedDiff<V> : never;
8
8
  type NestedDiff<V extends JSONValue> = (V extends JSONPrimitive ? {
9
9
  type: 'value';
10
- before: V;
11
10
  after: V;
12
11
  } : never) | (V extends JSONArray ? {
13
12
  type: 'splice';
package/dist/diff.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk6R7Z62HKjs = require('./chunk-6R7Z62HK.js');
3
+ var _chunkFZMNGRDIjs = require('./chunk-FZMNGRDI.js');
4
4
 
5
5
 
6
- exports.diffJson = _chunk6R7Z62HKjs.diffJson;
6
+ exports.diffJson = _chunkFZMNGRDIjs.diffJson;
package/dist/diff.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  diffJson
3
- } from "./chunk-SZTK7XV4.mjs";
3
+ } from "./chunk-A3OFRLHN.mjs";
4
4
  export {
5
5
  diffJson
6
6
  };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk6R7Z62HKjs = require('./chunk-6R7Z62HK.js');
3
+ var _chunkFZMNGRDIjs = require('./chunk-FZMNGRDI.js');
4
4
 
5
5
 
6
6
  var _chunkHLUKTMHVjs = require('./chunk-HLUKTMHV.js');
7
7
 
8
8
 
9
9
 
10
- exports.diffJson = _chunk6R7Z62HKjs.diffJson; exports.patchJson = _chunkHLUKTMHVjs.patchJson;
10
+ exports.diffJson = _chunkFZMNGRDIjs.diffJson; exports.patchJson = _chunkHLUKTMHVjs.patchJson;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  diffJson
3
- } from "./chunk-SZTK7XV4.mjs";
3
+ } from "./chunk-A3OFRLHN.mjs";
4
4
  import {
5
5
  patchJson
6
6
  } from "./chunk-KAHL2YAL.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcanejs/diff",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "description": "Create and apply JSON diffs of JSON objects",
6
6
  "keywords": [
@@ -38,12 +38,14 @@
38
38
  "import": "./dist/patch.mjs",
39
39
  "require": "./dist/patch.js",
40
40
  "types": "./dist/patch.d.ts"
41
- }
41
+ },
42
+ "./package.json": "./package.json"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/eslint": "^8.56.5",
45
46
  "@types/jest": "^29.5.12",
46
47
  "@types/node": "^20.11.24",
48
+ "check-export-map": "^1.3.1",
47
49
  "eslint": "^8.57.0",
48
50
  "jest": "^29.7.0",
49
51
  "ts-jest": "^29.2.0",
@@ -60,7 +62,7 @@
60
62
  },
61
63
  "scripts": {
62
64
  "lint": "eslint . --max-warnings 0",
63
- "build": "tsup",
65
+ "build": "rm -rf dist && tsup && check-export-map",
64
66
  "test": "jest",
65
67
  "test:watch": "jest --watch"
66
68
  }