Created
January 28, 2020 18:05
-
-
Save Sy1v4in/23db427474ac9ea4e25b0e11e95888c1 to your computer and use it in GitHub Desktop.
Piece of code showing how to use diffJson. Could be used to redefine a better tap extension…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Diff from 'diff' | |
import colors from 'colors/safe' | |
const diff = Diff.diffJson(postedData, expectedConversationManagerModel) | |
diff.forEach(part => { | |
const color = part.added ? 'green' : part.removed ? 'red' : 'grey' | |
process.stderr.write(colors[color](part.value)) | |
}) | |
console.log() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to install the
diff
andcolors
libraries, for instanceand types for typescript users