Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active November 4, 2019 15:09
Show Gist options
  • Save apaleslimghost/f3901c756ba39c1b34d1a86e74b5d13a to your computer and use it in GitHub Desktop.
Save apaleslimghost/f3901c756ba39c1b34d1a86e74b5d13a to your computer and use it in GitHub Desktop.
const {diffChars} = require('diff')
const c = require('ansi-colors')
const Result = require('folktale/result')
module.exports = ({ expected, value }) => (
expected === value
? Result.Ok()
: Result.Error(
c.red('- expected ') + c.green('+ actual\n') +
diffChars(expected, value)
.map(change => (
change.added
? c.green(change.value)
: change.removed
? c.red(change.value)
: change.value
))
.join('')
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment