Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unexpected

Package Overview
Dependencies
Maintainers
3
Versions
330
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unexpected - npm Package Compare versions

Comparing version 10.10.2 to 10.10.3

108

lib/styles.js

@@ -353,14 +353,29 @@ var utils = require('./utils');

expect.addStyle('diffFragment', function (text, baseStyle, specialCharStyle, markUpSpecialCharacters) {
if (markUpSpecialCharacters) {
text.split(specialCharRegExp).forEach(function (part) {
if (specialCharRegExp.test(part)) {
this[specialCharStyle || baseStyle](utils.escapeChar(part));
} else {
this[baseStyle](part);
}
}, this);
} else {
this[baseStyle](text);
}
expect.addStyle('stringDiffFragment', function (ch, text, baseStyle, markUpSpecialCharacters) {
text.split(/\n/).forEach(function (line, i, lines) {
if (this.isAtStartOfLine()) {
this.alt({
text: ch,
fallback: function () {
if (line === '' && ch !== ' ') {
this[ch === '+' ? 'diffAddedSpecialChar' : 'diffRemovedSpecialChar']('\\n');
}
}
});
}
if (markUpSpecialCharacters) {
line.split(specialCharRegExp).forEach(function (part) {
if (specialCharRegExp.test(part)) {
this[{'+': 'diffAddedSpecialChar', '-': 'diffRemovedSpecialChar'}[ch] || baseStyle](utils.escapeChar(part));
} else {
this[baseStyle](part);
}
}, this);
} else {
this[baseStyle](line);
}
if (i !== lines.length - 1) {
this.nl();
}
}, this);
});

@@ -381,6 +396,6 @@

lastPart = null;
} else if (lastPart) {
diffLines.push(lastPart);
lastPart = part;
} else {
if (lastPart) {
diffLines.push(lastPart);
}
lastPart = part;

@@ -397,3 +412,2 @@ }

var newValue = part.newValue;
var oldLine = this.clone();
var newLine = this.clone();

@@ -408,24 +422,12 @@ var oldEndsWithNewline = oldValue.slice(-1) === '\n';

}
stringDiff['diff' + type](oldValue, newValue).forEach(function (part) {
if (part.added) {
newLine.diffFragment(part.value, 'diffAddedHighlight', 'diffAddedSpecialChar', options.markUpSpecialCharacters);
newLine.stringDiffFragment('+', part.value, 'diffAddedHighlight', options.markUpSpecialCharacters);
} else if (part.removed) {
oldLine.diffFragment(part.value, 'diffRemovedHighlight', 'diffRemovedSpecialChar', options.markUpSpecialCharacters);
this.stringDiffFragment('-', part.value, 'diffRemovedHighlight', options.markUpSpecialCharacters);
} else {
newLine.diffAddedLine(part.value);
oldLine.diffRemovedLine(part.value);
newLine.stringDiffFragment('+', part.value, 'diffAddedLine');
this.stringDiffFragment('-', part.value, 'diffRemovedLine');
}
});
this.alt({
text: function () {
oldLine.prependLinesWith(this.clone().diffRemovedLine('-'));
newLine.prependLinesWith(this.clone().diffAddedLine('+'));
}
});
if (oldEndsWithNewline && !newEndsWithNewline) {
oldLine.diffRemovedSpecialChar('\\n');
}
}, this);
if (newEndsWithNewline && !oldEndsWithNewline) {

@@ -435,6 +437,6 @@ newLine.diffAddedSpecialChar('\\n');

this.append(oldLine).nl().append(newLine);
if (oldEndsWithNewline && index < diffLines.length - 1) {
this.nl();
if (oldEndsWithNewline && !newEndsWithNewline) {
this.diffRemovedSpecialChar('\\n');
}
this.nl().append(newLine).nl(oldEndsWithNewline && index < diffLines.length - 1 ? 1 : 0);
} else {

@@ -446,35 +448,7 @@ var endsWithNewline = /\n$/.test(part.value);

if (part.added) {
this.append(function () {
this.diffFragment(value, 'diffAddedLine', undefined, options.markUpSpecialCharacters);
var outer = this;
this.alt({
text: function () {
outer.prependLinesWith(function () {
this.diffAddedLine('+');
});
}
});
});
this.stringDiffFragment('+', value, 'diffAddedLine', options.markUpSpecialCharacters);
} else if (part.removed) {
this.append(function () {
this.diffFragment(value, 'diffRemovedLine', undefined, options.markUpSpecialCharacters);
var outer = this;
this.alt({
text: function () {
outer.prependLinesWith(function () {
this.diffRemovedLine('-');
});
}
});
});
this.stringDiffFragment('-', value, 'diffRemovedLine', options.markUpSpecialCharacters);
} else {
var outer = this;
this.alt({
text: function () {
outer.text(value.replace(/^(.)/gm, ' $1'));
},
fallback: function () {
this.text(value);
}
});
this.stringDiffFragment(' ', value, 'text');
}

@@ -481,0 +455,0 @@ if (endsWithNewline) {

@@ -1025,3 +1025,3 @@ var utils = require('./utils');

},
diffLimit: 1024,
diffLimit: 4096,
diff: function (actual, expected, output, diff, inspect) {

@@ -1028,0 +1028,0 @@ if (Math.max(actual.length, expected.length) > this.diffLimit) {

{
"name": "unexpected",
"version": "10.10.2",
"version": "10.10.3",
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>",

@@ -29,3 +29,3 @@ "keywords": [

"leven": "1.0.0",
"magicpen": "5.7.0",
"magicpen": "5.9.0",
"unexpected-bluebird": "2.9.34"

@@ -32,0 +32,0 @@ },

Sorry, the diff of this file is too big to display

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