Socket
Socket
Sign inDemoInstall

jest-diff

Package Overview
Dependencies
Maintainers
3
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-diff - npm Package Compare versions

Comparing version 14.3.1-alpha.410cb91a to 14.3.2-alpha.83c25417

45

build/diffStrings.js

@@ -29,5 +29,3 @@ /**

function diffStrings(a, b, options) {
const multiline = a.match(/[\r\n]/) !== -1 && b.indexOf('\n') !== -1;
let isDifferent = false;
let result;

@@ -38,34 +36,21 @@ // `diff` uses the Myers LCS diff algorithm which runs in O(n+d^2) time

// whenever linebreaks are involved.
if (multiline) {
result = jsDiff.diffLines(a, b).map(part => {
if (part.added || part.removed) {
isDifferent = true;
}
const result = jsDiff.diffLines(a, b).map(part => {
if (part.added || part.removed) {
isDifferent = true;
}
const lines = part.value.split('\n');
const color = part.added ?
chalk.red :
part.removed ? chalk.green : chalk.white;
const lines = part.value.split('\n');
const color = part.added ?
chalk.red :
part.removed ? chalk.green : chalk.white;
if (lines[lines.length - 1] === '') {
lines.pop();
}
if (lines[lines.length - 1] === '') {
lines.pop();
}
return lines.map(line => {
const mark = color(part.added ? '+' : part.removed ? '-' : ' ');
return mark + ' ' + color(line) + '\n';
}).join('');
}).join('').trim();
} else {
result = jsDiff.diffChars(a, b).map(part => {
if (part.added || part.removed) {
isDifferent = true;
}
const color = part.added ?
chalk.green :
part.removed ? chalk.red : chalk.dim;
return color(part.value);
return lines.map(line => {
const mark = color(part.added ? '+' : part.removed ? '-' : ' ');
return mark + ' ' + color(line) + '\n';
}).join('');
}
}).join('').trim();

@@ -72,0 +57,0 @@ if (isDifferent) {

@@ -40,3 +40,7 @@ /**

case 'string':
return diffStrings(String(a), String(b), options);
const multiline = a.match(/[\r\n]/) !== -1 && b.indexOf('\n') !== -1;
if (multiline) {
return diffStrings(String(a), String(b), options);
}
return null;
case 'number':

@@ -43,0 +47,0 @@ case 'boolean':

{
"name": "jest-diff",
"version": "14.3.1-alpha.410cb91a",
"version": "14.3.2-alpha.83c25417",
"repository": {

@@ -13,3 +13,3 @@ "type": "git",

"diff": "^3.0.0",
"jest-matcher-utils": "^14.3.1-alpha.410cb91a",
"jest-matcher-utils": "^14.3.2-alpha.83c25417",
"pretty-format": "^3.6.0"

@@ -16,0 +16,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc