Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,29 @@ Output:
]
}
```

`applyDeltaDiff(newStruct, delta)`

Apply the delta to return the oldStruct structure.

Simple usage:

```ts
import { applyDeltaDiff } from 'json-difference'

const coffee = { color: { color1: 'black', color2: 'brown' }, special: true }
const oil = { color: { color1: 'red', color2: 'blue' }, special2: false, especial3: [{}] }

// Get JsonDiff delta and applyDeltaDiff
let delta = getDiff(coffee, oil, true)
const oldStruct = applyDeltaDiff(struct2, delta)

console.log(oldStruct)
```

Output:

```json
// Coffee
{ "color": { "color1": "black", "color2": "brown" }, "special": true }
```
Loading