1.0.7 • Published 2 years ago

wtdiff v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

WTDiff!

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.

Why?

KISS - Keep it simple and stupid

  1. We need to keep changes predictable
  2. Our consuming source does not need to know about what has not changed
  3. The consuming source should simply run the updates based on all the fields sent

Let's get to it

CommonJS

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"
  }
*/

ES Modules

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"
  }
*/

Supporting

  • Nested objects
  • [] Nested arrays
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago