Socket
Socket
Sign inDemoInstall

pretty-format

Package Overview
Dependencies
Maintainers
3
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty-format - npm Package Compare versions

Comparing version 18.1.0 to 18.5.0-alpha.7da3df39

build/plugins/AsymmetricMatcher.js

7

build/index.js

@@ -13,3 +13,2 @@ /**

const style = require('ansi-styles');
const printString = require('./printString');

@@ -87,3 +86,3 @@ const toString = Object.prototype.toString;

if (typeOf === 'string') {
return '"' + printString(val) + '"';
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
}

@@ -119,3 +118,4 @@ if (typeOf === 'function') {

if (escapeRegex) {
return printString(regExpToString.call(val));
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
}

@@ -316,2 +316,3 @@ return regExpToString.call(val);

edgeSpacing,
min,
spacing };

@@ -318,0 +319,0 @@

@@ -11,3 +11,3 @@ /**

const printString = require('../printString');
const escapeHTML = require('./escapeHTML');

@@ -29,3 +29,3 @@ const reactElement = Symbol.for('react.element');

} else if (typeof node === 'string') {
return printString(colors.content.open + node + colors.content.close);
return colors.content.open + escapeHTML(node) + colors.content.close;
} else {

@@ -72,2 +72,7 @@ return print(node);

const opaqueChildren = element.props.children;
const hasProps = !!Object.keys(element.props).
filter(propName => propName !== 'children').
length;
const closeInNewLine = hasProps && !opts.min;
if (opaqueChildren) {

@@ -79,5 +84,5 @@ const flatChildren = [];

const children = printChildren(flatChildren, print, indent, colors, opts);
result += colors.tag.open + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + elementName + '>' + colors.tag.close;
result += colors.tag.open + (closeInNewLine ? '\n' : '') + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + elementName + '>' + colors.tag.close;
} else {
result += colors.tag.open + ' />' + colors.tag.close;
result += colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
}

@@ -84,0 +89,0 @@

@@ -11,3 +11,3 @@ /**

const printString = require('../printString');
const escapeHTML = require('./escapeHTML');

@@ -41,3 +41,3 @@ const reactTestInstance = Symbol.for('react.test.json');

} else if (typeof instance === 'string') {
return printString(colors.content.open + instance + colors.content.close);
return colors.content.open + escapeHTML(instance) + colors.content.close;
}

@@ -51,7 +51,9 @@

const closeInNewLine = !!Object.keys(instance.props).length && !opts.min;
if (instance.children) {
const children = printChildren(instance.children, print, indent, colors, opts);
result += colors.tag.open + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + instance.type + '>' + colors.tag.close;
result += colors.tag.open + (closeInNewLine ? '\n' : '') + '>' + colors.tag.close + opts.edgeSpacing + indent(children) + opts.edgeSpacing + colors.tag.open + '</' + instance.type + '>' + colors.tag.close;
} else {
result += colors.tag.open + ' />' + colors.tag.close;
result += colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
}

@@ -58,0 +60,0 @@

{
"name": "pretty-format",
"version": "18.1.0",
"version": "18.5.0-alpha.7da3df39",
"repository": {

@@ -12,9 +12,5 @@ "type": "git",

"author": "James Kyle <me@thejameskyle.com>",
"scripts": {
"test": "../../packages/jest-cli/bin/jest.js",
"perf": "node perf/test.js"
},
"dependencies": {
"ansi-styles": "^2.2.1"
"ansi-styles": "^3.0.0"
}
}

@@ -17,3 +17,3 @@ /**

const React = require('react');
const ReactTestRenderer = require('react/lib/ReactTestRenderer');
const ReactTestRenderer = require('react-test-renderer');
const ReactTestComponent = require('../build/plugins/ReactTestComponent');

@@ -58,3 +58,3 @@

'prettyFormat() ',
() => prettyFormat(value, prettyFormatOpts),
() => prettyFormat(value, prettyFormatOpts)
);

@@ -78,3 +78,3 @@

const winner = results[0];
results.forEach((item, index) => {

@@ -208,5 +208,5 @@ item.isWinner = index === 0;

React.createElement('div', null,
React.createElement('div'),
),
),
React.createElement('div')
)
)
);

@@ -213,0 +213,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