Skip to content

Commit c8d38c7

Browse files
committed
Removed deletedValue; Replace with oldValue
1 parent d5fce21 commit c8d38c7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ const diff = require("microdiff").default;
5252
There are three different types of changes. `CREATE`, `REMOVE`, and `CHANGE`.
5353
The `path` property gives a path to the property in the new object (or the old object in the case of `REMOVE`).
5454
Each element in the paths is a key to the next property a level deeper until you get to the property changed, and it is string or a number, depending on whether the object is an Array or Object (Objects with number keys will still be strings).
55-
The `value` (`deletedValue` in the case of `REMOVE`) property exists in types `CREATE`, `CHANGE` and `REMOVE`, and it contains the value of the property added/changed/deleted.
56-
The `oldValue` property exists in the type `CHANGE`, and it contains the old value of the property changed.
55+
The `value` property exists in types `CREATE` and `CHANGE`, and it contains the value of the property added/changed/deleted.
56+
The `oldValue` property exists in the type `CHANGE` and `REMOVE`, and it contains the old value of the property.
57+
5758
# Cycles support
5859

5960
By default cycles are supported, but if you are sure that the object has no cycles (for example if you are parsing JSON) you can disable cycles using the `cyclesFix` option.

index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ interface Difference {
33
path: (string | number)[];
44
value?: any;
55
oldValue?: any;
6-
deletedValue?: any;
76
}
87
interface Options {
98
cyclesFix: boolean;
@@ -28,7 +27,7 @@ export default function diff(
2827
diffs.push({
2928
type: "REMOVE",
3029
path: [path],
31-
deletedValue: obj[key]
30+
oldValue: obj[key],
3231
});
3332
continue;
3433
}
@@ -68,7 +67,7 @@ export default function diff(
6867
path: [path],
6968
type: "CHANGE",
7069
value: newObjKey,
71-
oldValue: objKey
70+
oldValue: objKey,
7271
});
7372
}
7473
}

0 commit comments

Comments
 (0)