1.0.0 • Published 4 years ago

fake-diff v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

fake-diff

fake-diff is a tiny Node.js plugin that you can include in your projects. You can install it via following command:

npm install fake-diff

Usage

Simply compare two strings as the first and second argument:

const fakeDiff = require('fake-diff')
console.log(fakeDiff(oldString, newString))

Example output:

npm.io

Or you can pass files:

const fs = require('fs')
const fakeDiff = require('fake-diff')
const oldFileContent = fs.readFileSync(__dirname  +  "/oldFile.txt",  "utf-8")
const newFileContent = fs.readFileSync(__dirname  +  "/newFile.txt",  "utf-8")
console.log(fakeDiff(oldFileContent, newFileContent))

Also takes the following options as an object in the third parameter: fakeDiff(oldFile, newFile, options) | Option | Type | Default Value | |--|--|--| | hideLines | boolean | true | | maxAdjacentStaticLines | number | 1

Credit

Relies on diff (npm package) to generate line diffs, and chalk for coloring.

Alternatives: git-diff (npm package)

License

MIT