fake-diff
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/fake-diff package

1.0.0 • Public • Published

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:

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

Readme

Keywords

Package Sidebar

Install

npm i fake-diff

Weekly Downloads

81

Version

1.0.0

License

MIT

Unpacked Size

238 kB

Total Files

6

Last publish

Collaborators

  • onurkerimov