Spanned from a problem I had at work while dealing with deciding what to send as part of the payload.
Rule of thumb from experience, just send what's necessary to make the update.
KISS - Keep it simple and stupid
- We need to keep changes predictable
- Our consuming source does not need to know about what has not changed
- The consuming source should simply run the updates based on all the fields sent
const wtdiff = require("wtdiff")
const dude1 = {name: "dude", job: "guitar player"}
const dude2 = {name: "dude", job: "developer"}
cosnt changes = wtdiff.extractChanges(dude1, dude2)
console.log(changes)
/**
{
job: "developer"
}
*/
import wtdiff from 'wtdiff'
const dude1 = {name: "dude", job: "guitar player"}
const dude2 = {name: "dude", job: "developer"}
cosnt changes = wtdiff.extractChanges(dude1, dude2)
console.log(changes)
/**
{
job: "developer"
}
*/
- Nested objects
- [] Nested arrays