Skip to content

Commit f2a148b

Browse files
committed
Added CommonJS example
1 parent 9390265 commit f2a148b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ console.log(diff(obj1, obj2));
4343
// [{type: "CREATE", path: ["newProperty"], value: "new"}]
4444
```
4545

46+
If you are using CommonJS, you can import it like this:
47+
48+
```js
49+
const diff = require("microdiff").default;
50+
```
51+
4652
There are three different types of changes. `CREATE`, `REMOVE`, and `CHANGE`. The `path` property gives a path to the property in the new object (or the old object in the case of `REMOVE`). Each element in the array is a key to the next property a level deeper until you get to the property changed. The `value` property exists in types `CREATE` and `CHANGE`, and it contains the value of the property added/changed.
4753

4854
# Benchmarks

0 commit comments

Comments
 (0)