index.js
function inlineDiff (actual, expected, formatAdd, formatRem) {
  var result = diff.diffWordsWithSpace(actual, expected)
    .map(function (line, idx) {
      if (line.added) { return formatLinesWith(formatAdd, line.value) }
      return line.removed
        ? formatLinesWith(formatRem, line.value)
        : line.value
    })
    .join('')

  var lines = result.split('\n')
  if (lines.length > 4) {
    result = lines
      .map(function (line, idx) {
        return lpad(idx + 1, String(lines.length).length) + ' | ' + line
      })
      .join('\n')
  }

  return formatRem('actual') + ' ' + formatAdd('expected') + '\n\n' + result
}
function inlineDiff (actual, expected, formatAdd, formatRem) {
  var result = diff.diffWordsWithSpace(actual, expected)
    .map(function (line, idx) {
      if (line.added) { return formatLinesWith(formatAdd, line.value) }
      return line.removed
        ? formatLinesWith(formatRem, line.value)
        : line.value
    })
    .join('')

  var lines = result.split('\n')
  if (lines.length > 4) {
    result = lines
      .map(function (line, idx) {
        return lpad(idx + 1, String(lines.length).length) + ' | ' + line
      })
      .join('\n')
  }

  return formatRem('actual') + ' ' + formatAdd('expected') + '\n\n' + result
}
function inlineDiff ( actual , expected , formatAdd , formatRem ) { var result = diff . diffWordsWithSpace ( actual , expected ) . map ( function ( line , idx ) { if ( line . added ) { return formatLinesWith ( formatAdd , line . value ) } return line . removed ? formatLinesWith ( formatRem , line . value ) : line . value } ) . join ( '' ) var lines = result . split ( '\n' ) if ( lines . length > 4 ) { result = lines . map ( function ( line , idx ) { return lpad ( idx + 1 , String ( lines . length ) . length ) + ' | ' + line } ) . join ( '\n' ) } return formatRem ( 'actual' ) + ' ' + formatAdd ( 'expected' ) + '\n\n' + result }
Return inline diff of actual vs expected.

@param {*} actual Actual value
@param {*} expected Expected value
@param {function} formatAdd Addition formatter
@param {function} formatRem Removal formatter
@return {string}
Return inline diff of actual vs expected .