* Return a character diff for `err`. * * @param {Error} err * @return {String} * @api private
(err, type, escape)
| 2038 | */ |
| 2039 | |
| 2040 | function errorDiff(err, type, escape) { |
| 2041 | return diff['diff' + type](err.actual, err.expected).map(function(str){ |
| 2042 | if (escape) { |
| 2043 | str.value = str.value |
| 2044 | .replace(/\t/g, '<tab>') |
| 2045 | .replace(/\r/g, '<CR>') |
| 2046 | .replace(/\n/g, '<LF>\n'); |
| 2047 | } |
| 2048 | if (str.added) return colorLines('diff added', str.value); |
| 2049 | if (str.removed) return colorLines('diff removed', str.value); |
| 2050 | return str.value; |
| 2051 | }).join(''); |
| 2052 | } |
| 2053 | |
| 2054 | /** |
| 2055 | * Color lines for `str`, using the color `name`. |