nwdiff

1.0.3 • Public • Published

nwdiff

Generate word-level diff output between two strings like GNU wdiff. Colored (optionally) with chalk.

import nwdiff from 'nwdiff'

nwdiff('one and two', 'ne anwooo')
// === '[-o-]ne an[-d t-]wo{+oo+}' (maybe with color ANSI sequences)

// or custom options (defaults below)
nwdiff('one and two', 'ne anwooo', {
  delimiters: false, // Whether to print delimiters for start/end
  startInsert: '{+',
  endInsert: '+}',
  startDelete: '[-',
  endDelete: '-]',
  color: undefined, // Whether to use color, default auto-detected
  // These colors are `chalk` colors:
  colorContext = 'gray',
  colorInsert = 'black',
  bgColorInsert = 'bgGreenBright',
  colorDelete = 'black',
  bgColorDelete = 'bgRedBright',
  colorDelimiter = 'black',
  bgColorDelimiter = 'bgWhite'
})

Readme

Keywords

none

Package Sidebar

Install

npm i nwdiff

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

7.29 kB

Total Files

4

Last publish

Collaborators

  • andersdjohnson