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

pretty-format

Package Overview
Dependencies
Maintainers
5
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 22.4.0 to 22.4.3

247

build/collections.js

@@ -1,178 +0,139 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.printIteratorEntries = printIteratorEntries;
exports.printIteratorValues = printIteratorValues;
exports.printListItems = printListItems;
exports.printObjectProperties = printObjectProperties;
const getSymbols = Object.getOwnPropertySymbols || (obj => []); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const isSymbol = key =>
// $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value
typeof key === 'symbol' || toString.call(key) === '[object Symbol]';
// Return entries (for example, of a map)
// with spacing, indentation, and comma
// without surrounding punctuation (for example, braces)
function printIteratorEntries(
// Flow 0.51.0: property `@@iterator` of $Iterator not found in Object
// To allow simplistic getRecordIterator in immutable.js
iterator, config, indentation, depth, refs, printer) {
let separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';
let result = '';
let current = iterator.next();
if (!current.done) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
while (!current.done) {
const name = printer(current.value[0], config, indentationNext, depth, refs);
const value = printer(current.value[1], config, indentationNext, depth, refs);
result += indentationNext + name + separator + value;
current = iterator.next();
if (!current.done) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
// Return values (for example, of a set)
// with spacing, indentation, and comma
// without surrounding punctuation (braces or brackets)
function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
let result = '';
let current = iterator.next();
if (!current.done) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
while (!current.done) {
result += indentationNext + printer(current.value, config, indentationNext, depth, refs);
printIteratorEntries = printIteratorEntries;exports.
current = iterator.next();
if (!current.done) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
// Return items (for example, of an array)
// with spacing, indentation, and comma
// without surrounding punctuation (for example, brackets)
function printListItems(list, config, indentation, depth, refs, printer) {
let result = '';
if (list.length) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
for (let i = 0; i < list.length; i++) {
result += indentationNext + printer(list[i], config, indentationNext, depth, refs);
if (i < list.length - 1) {
result += ',' + config.spacingInner;
} else if (!config.min) {
result += ',';
}
}
result += config.spacingOuter + indentation;
}
return result;
}
// Return properties of an object
// with spacing, indentation, and comma
// without surrounding punctuation (for example, braces)
function printObjectProperties(val, config, indentation, depth, refs, printer) {
let result = '';
let keys = Object.keys(val).sort();
const symbols = getSymbols(val);
if (symbols.length) {
keys = keys.filter(key => !isSymbol(key)).concat(symbols);
}
if (keys.length) {
result += config.spacingOuter;
const indentationNext = indentation + config.indent;
printIteratorValues = printIteratorValues;exports.
printListItems = printListItems;exports.
printObjectProperties = printObjectProperties;const getSymbols = Object.getOwnPropertySymbols || (obj => []); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const isSymbol = key => // $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value
typeof key === 'symbol' || toString.call(key) === '[object Symbol]'; // Return entries (for example, of a map)
// with spacing, indentation, and comma
// without surrounding punctuation (for example, braces)
function printIteratorEntries( // Flow 0.51.0: property `@@iterator` of $Iterator not found in Object
// To allow simplistic getRecordIterator in immutable.js
iterator, config, indentation, depth, refs, printer) {let separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';let result = '';let current = iterator.next();if (!current.done) {result += config.spacingOuter;const indentationNext = indentation + config.indent;while (!current.done) {const name = printer(current.value[0], config, indentationNext, depth, refs);const value = printer(current.value[1], config, indentationNext, depth, refs);result += indentationNext + name + separator + value;current = iterator.next();if (!current.done) {result += ',' + config.spacingInner;} else if (!config.min) {result += ',';}}result += config.spacingOuter + indentation;}return result;} // Return values (for example, of a set)
// with spacing, indentation, and comma
// without surrounding punctuation (braces or brackets)
function printIteratorValues(iterator, config, indentation, depth, refs, printer) {let result = '';let current = iterator.next();if (!current.done) {result += config.spacingOuter;const indentationNext = indentation + config.indent;while (!current.done) {result += indentationNext + printer(current.value, config, indentationNext, depth, refs);current = iterator.next();if (!current.done) {result += ',' + config.spacingInner;} else if (!config.min) {result += ',';}}result += config.spacingOuter + indentation;}return result;} // Return items (for example, of an array)
// with spacing, indentation, and comma
// without surrounding punctuation (for example, brackets)
function printListItems(list, config, indentation, depth, refs, printer) {let result = '';if (list.length) {result += config.spacingOuter;const indentationNext = indentation + config.indent;for (let i = 0; i < list.length; i++) {result += indentationNext + printer(list[i], config, indentationNext, depth, refs);if (i < list.length - 1) {result += ',' + config.spacingInner;} else if (!config.min) {result += ',';}}result += config.spacingOuter + indentation;}return result;} // Return properties of an object
// with spacing, indentation, and comma
// without surrounding punctuation (for example, braces)
function printObjectProperties(val, config, indentation, depth, refs, printer) {let result = '';let keys = Object.keys(val).sort();const symbols = getSymbols(val);if (symbols.length) {keys = keys.filter(key => !isSymbol(key)).concat(symbols);}if (keys.length) {result += config.spacingOuter;const indentationNext = indentation + config.indent;for (let i = 0; i < keys.length; i++) {const key = keys[i];
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const name = printer(key, config, indentationNext, depth, refs);

@@ -179,0 +140,0 @@ const value = printer(val[key], config, indentationNext, depth, refs);

'use strict';
var _ansiStyles = require('ansi-styles');
var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
var _collections = require('./collections');
var _asymmetric_matcher = require('./plugins/asymmetric_matcher');
var _asymmetric_matcher2 = _interopRequireDefault(_asymmetric_matcher);
var _convert_ansi = require('./plugins/convert_ansi');
var _convert_ansi2 = _interopRequireDefault(_convert_ansi);
var _dom_collection = require('./plugins/dom_collection');
var _dom_collection2 = _interopRequireDefault(_dom_collection);
var _dom_element = require('./plugins/dom_element');
var _dom_element2 = _interopRequireDefault(_dom_element);
var _immutable = require('./plugins/immutable');
var _immutable2 = _interopRequireDefault(_immutable);
var _react_element = require('./plugins/react_element');
var _react_element2 = _interopRequireDefault(_react_element);
var _react_test_component = require('./plugins/react_test_component');
var _react_test_component2 = _interopRequireDefault(_react_test_component);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _ansiStyles = require('ansi-styles');var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
const toString = Object.prototype.toString;
const toISOString = Date.prototype.toISOString;
const errorToString = Error.prototype.toString;
const regExpToString = RegExp.prototype.toString;
const symbolToString = Symbol.prototype.toString;
var _collections = require('./collections');
var _asymmetric_matcher = require('./plugins/asymmetric_matcher');var _asymmetric_matcher2 = _interopRequireDefault(_asymmetric_matcher);
var _convert_ansi = require('./plugins/convert_ansi');var _convert_ansi2 = _interopRequireDefault(_convert_ansi);
var _dom_collection = require('./plugins/dom_collection');var _dom_collection2 = _interopRequireDefault(_dom_collection);
var _dom_element = require('./plugins/dom_element');var _dom_element2 = _interopRequireDefault(_dom_element);
var _immutable = require('./plugins/immutable');var _immutable2 = _interopRequireDefault(_immutable);
var _react_element = require('./plugins/react_element');var _react_element2 = _interopRequireDefault(_react_element);
var _react_test_component = require('./plugins/react_test_component');var _react_test_component2 = _interopRequireDefault(_react_test_component);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const toString = Object.prototype.toString;const toISOString = Date.prototype.toISOString;const errorToString = Error.prototype.toString;const regExpToString = RegExp.prototype.toString;const symbolToString = Symbol.prototype.toString;
// Explicitly comparing typeof constructor to function avoids undefined as name
// when mock identity-obj-proxy returns the key as the value for any key.
const getConstructorName = val =>
typeof val.constructor === 'function' && val.constructor.name || 'Object';
const getConstructorName = val => typeof val.constructor === 'function' && val.constructor.name || 'Object';

@@ -62,20 +70,7 @@ // Is val is equal to global window object? Works even if it does not exist :)

this.name = this.constructor.name;
}}
}
}
function isToStringedArrayType(toStringed) {
return (
toStringed === '[object Array]' ||
toStringed === '[object ArrayBuffer]' ||
toStringed === '[object DataView]' ||
toStringed === '[object Float32Array]' ||
toStringed === '[object Float64Array]' ||
toStringed === '[object Int8Array]' ||
toStringed === '[object Int16Array]' ||
toStringed === '[object Int32Array]' ||
toStringed === '[object Uint8Array]' ||
toStringed === '[object Uint8ClampedArray]' ||
toStringed === '[object Uint16Array]' ||
toStringed === '[object Uint32Array]');
return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';
}

@@ -102,7 +97,3 @@

function printBasicValue(
val,
printFunctionName,
escapeRegex)
{
function printBasicValue(val, printFunctionName, escapeRegex) {
if (val === true || val === false) {

@@ -141,6 +132,3 @@ return '' + val;

}
if (
toStringed === '[object Function]' ||
toStringed === '[object GeneratorFunction]')
{
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') {
return printFunction(val, printFunctionName);

@@ -172,10 +160,3 @@ }

function printComplexValue(
val,
config,
indentation,
depth,
refs,
hasCalledToJSON)
{
function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
if (refs.indexOf(val) !== -1) {

@@ -190,9 +171,3 @@ return '[Circular]';

if (
config.callToJSON &&
!hitMaxDepth &&
val.toJSON &&
typeof val.toJSON === 'function' &&
!hasCalledToJSON)
{
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function' && !hasCalledToJSON) {
return printer(val.toJSON(), config, indentation, depth, refs, true);

@@ -203,45 +178,12 @@ }

if (toStringed === '[object Arguments]') {
return hitMaxDepth ?
'[Arguments]' :
(min ? '' : 'Arguments ') +
'[' +
(0, _collections.printListItems)(val, config, indentation, depth, refs, printer) +
']';
return hitMaxDepth ? '[Arguments]' : (min ? '' : 'Arguments ') + '[' + (0, _collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
}
if (isToStringedArrayType(toStringed)) {
return hitMaxDepth ?
'[' + val.constructor.name + ']' :
(min ? '' : val.constructor.name + ' ') +
'[' +
(0, _collections.printListItems)(val, config, indentation, depth, refs, printer) +
']';
return hitMaxDepth ? '[' + val.constructor.name + ']' : (min ? '' : val.constructor.name + ' ') + '[' + (0, _collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
}
if (toStringed === '[object Map]') {
return hitMaxDepth ?
'[Map]' :
'Map {' +
(0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer,
' => ') +
'}';
return hitMaxDepth ? '[Map]' : 'Map {' + (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer, ' => ') + '}';
}
if (toStringed === '[object Set]') {
return hitMaxDepth ?
'[Set]' :
'Set {' +
(0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer) +
'}';
return hitMaxDepth ? '[Set]' : 'Set {' + (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + '}';
}

@@ -251,40 +193,17 @@

// For example, not even relevant if window is prop of React element.
return hitMaxDepth || isWindow(val) ?
'[' + getConstructorName(val) + ']' :
(min ? '' : getConstructorName(val) + ' ') +
'{' +
(0, _collections.printObjectProperties)(val, config, indentation, depth, refs, printer) +
'}';
return hitMaxDepth || isWindow(val) ? '[' + getConstructorName(val) + ']' : (min ? '' : getConstructorName(val) + ' ') + '{' + (0, _collections.printObjectProperties)(val, config, indentation, depth, refs, printer) + '}';
}
function printPlugin(
plugin,
val,
config,
indentation,
depth,
refs)
{
function printPlugin(plugin, val, config, indentation, depth, refs) {
let printed;
try {
printed = plugin.serialize ?
plugin.serialize(val, config, indentation, depth, refs, printer) :
plugin.print(
val,
valChild => printer(valChild, config, indentation, depth, refs),
str => {
printed = plugin.serialize ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, valChild => printer(valChild, config, indentation, depth, refs), str => {
const indentationNext = indentation + config.indent;
return (
indentationNext +
str.replace(NEWLINE_REGEXP, '\n' + indentationNext));
},
{
return indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext);
}, {
edgeSpacing: config.spacingOuter,
min: config.min,
spacing: config.spacingInner },
config.colors);
spacing: config.spacingInner
}, config.colors);
} catch (error) {

@@ -294,5 +213,3 @@ throw new PrettyFormatPluginError(error.message, error.stack);

if (typeof printed !== 'string') {
throw new Error(
`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
throw new Error(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
}

@@ -316,10 +233,3 @@ return printed;

function printer(
val,
config,
indentation,
depth,
refs,
hasCalledToJSON)
{
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
const plugin = findPlugin(config.plugins, val);

@@ -330,7 +240,3 @@ if (plugin !== null) {

const basicResult = printBasicValue(
val,
config.printFunctionName,
config.escapeRegex);
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex);
if (basicResult !== null) {

@@ -340,10 +246,3 @@ return basicResult;

return printComplexValue(
val,
config,
indentation,
depth,
refs,
hasCalledToJSON);
return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
}

@@ -356,5 +255,5 @@

tag: 'cyan',
value: 'green' };
value: 'green'
};
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);

@@ -371,5 +270,5 @@

printFunctionName: true,
theme: DEFAULT_THEME };
theme: DEFAULT_THEME
};
function validateOptions(options) {

@@ -383,5 +282,3 @@ Object.keys(options).forEach(key => {

if (options.min && options.indent !== undefined && options.indent !== 0) {
throw new Error(
'pretty-format: Options "min" and "indent" cannot be used together.');
throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
}

@@ -395,5 +292,3 @@

if (typeof options.theme !== 'object') {
throw new Error(
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`);
throw new Error(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`);
}

@@ -406,17 +301,8 @@ }

) => DEFAULT_THEME_KEYS.reduce((colors, key) => {
const value =
options.theme && options.theme[key] !== undefined ?
options.theme[key] :
DEFAULT_THEME[key];
const value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key];
const color = _ansiStyles2.default[value];
if (
color &&
typeof color.close === 'string' &&
typeof color.open === 'string')
{
if (color && typeof color.close === 'string' && typeof color.open === 'string') {
colors[key] = color;
} else {
throw new Error(
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
}

@@ -433,44 +319,19 @@ return colors;

const getPrintFunctionName = options =>
options && options.printFunctionName !== undefined ?
options.printFunctionName :
DEFAULT_OPTIONS.printFunctionName;
const getPrintFunctionName = options => options && options.printFunctionName !== undefined ? options.printFunctionName : DEFAULT_OPTIONS.printFunctionName;
const getEscapeRegex = options =>
options && options.escapeRegex !== undefined ?
options.escapeRegex :
DEFAULT_OPTIONS.escapeRegex;
const getEscapeRegex = options => options && options.escapeRegex !== undefined ? options.escapeRegex : DEFAULT_OPTIONS.escapeRegex;
const getConfig = options => ({
callToJSON:
options && options.callToJSON !== undefined ?
options.callToJSON :
DEFAULT_OPTIONS.callToJSON,
colors:
options && options.highlight ?
getColorsHighlight(options) :
getColorsEmpty(),
callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON,
colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(),
escapeRegex: getEscapeRegex(options),
indent:
options && options.min ?
'' :
createIndent(
options && options.indent !== undefined ?
options.indent :
DEFAULT_OPTIONS.indent),
maxDepth:
options && options.maxDepth !== undefined ?
options.maxDepth :
DEFAULT_OPTIONS.maxDepth,
indent: options && options.min ? '' : createIndent(options && options.indent !== undefined ? options.indent : DEFAULT_OPTIONS.indent),
maxDepth: options && options.maxDepth !== undefined ? options.maxDepth : DEFAULT_OPTIONS.maxDepth,
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
plugins:
options && options.plugins !== undefined ?
options.plugins :
DEFAULT_OPTIONS.plugins,
plugins: options && options.plugins !== undefined ? options.plugins : DEFAULT_OPTIONS.plugins,
printFunctionName: getPrintFunctionName(options),
spacingInner: options && options.min ? ' ' : '\n',
spacingOuter: options && options.min ? '' : '\n' });
spacingOuter: options && options.min ? '' : '\n'
});
function createIndent(indent) {

@@ -491,7 +352,3 @@ return new Array(indent + 1).join(' ');

const basicResult = printBasicValue(
val,
getPrintFunctionName(options),
getEscapeRegex(options));
const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options));
if (basicResult !== null) {

@@ -511,5 +368,5 @@ return basicResult;

ReactElement: _react_element2.default,
ReactTestComponent: _react_test_component2.default };
ReactTestComponent: _react_test_component2.default
};
module.exports = prettyFormat;

@@ -1,25 +0,23 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.serialize = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _collections = require('../collections');
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');
const SPACE = ' ';
var _collections = require('../collections'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher');const SPACE = ' ';const serialize = exports.serialize = (val, config,
indentation,
depth,
refs,
printer) =>
{
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => {
const stringedValue = val.toString();

@@ -31,9 +29,3 @@

}
return (
stringedValue +
SPACE +
'[' +
(0, _collections.printListItems)(val.sample, config, indentation, depth, refs, printer) +
']');
return stringedValue + SPACE + '[' + (0, _collections.printListItems)(val.sample, config, indentation, depth, refs, printer) + ']';
}

@@ -45,32 +37,11 @@

}
return (
stringedValue +
SPACE +
'{' +
(0, _collections.printObjectProperties)(
val.sample,
config,
indentation,
depth,
refs,
printer) +
'}');
return stringedValue + SPACE + '{' + (0, _collections.printObjectProperties)(val.sample, config, indentation, depth, refs, printer) + '}';
}
if (stringedValue === 'StringMatching') {
return (
stringedValue +
SPACE +
printer(val.sample, config, indentation, depth, refs));
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
}
if (stringedValue === 'StringContaining') {
return (
stringedValue +
SPACE +
printer(val.sample, config, indentation, depth, refs));
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
}

@@ -81,4 +52,4 @@

const test = exports.test = val => val && val.$$typeof === asymmetricMatcher;exports.default =
const test = exports.test = val => val && val.$$typeof === asymmetricMatcher;
{ serialize, test };
exports.default = { serialize, test };

@@ -1,15 +0,18 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.serialize = exports.test = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _ansiRegex = require('ansi-regex');
var _ansiRegex2 = _interopRequireDefault(_ansiRegex);
var _ansiStyles = require('ansi-styles');
var _ansiStyles2 = _interopRequireDefault(_ansiStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _ansiRegex = require('ansi-regex');var _ansiRegex2 = _interopRequireDefault(_ansiRegex);
var _ansiStyles = require('ansi-styles');var _ansiStyles2 = _interopRequireDefault(_ansiStyles);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
const toHumanReadableAnsi = text => {

@@ -58,4 +61,4 @@ return text.replace((0, _ansiRegex2.default)(), (match, offset, string) => {

default:
return '';}
return '';
}
});

@@ -69,9 +72,8 @@ }; /**

*
*/const test = exports.test = val => typeof val === 'string' && val.match((0, _ansiRegex2.default)());const serialize = exports.serialize = (val, config,
indentation,
depth,
refs,
printer) =>
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);exports.default =
*/
{ serialize, test };
const test = exports.test = val => typeof val === 'string' && val.match((0, _ansiRegex2.default)());
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
exports.default = { serialize, test };

@@ -1,23 +0,25 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.serialize = exports.test = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _collections = require('../collections');
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const SPACE = ' ';
const COLLECTION_NAMES = ['DOMStringMap', 'NamedNodeMap'];
const test = exports.test = val => val && val.constructor && COLLECTION_NAMES.indexOf(val.constructor.name) !== -1;
var _collections = require('../collections'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const SPACE = ' ';const COLLECTION_NAMES = ['DOMStringMap', 'NamedNodeMap'];const test = exports.test = val => val &&
val.constructor &&
COLLECTION_NAMES.indexOf(val.constructor.name) !== -1;
const convertCollectionToObject = collection => {

@@ -37,10 +39,3 @@ let result = {};

const serialize = exports.serialize = (
collection,
config,
indentation,
depth,
refs,
printer) =>
{
const serialize = exports.serialize = (collection, config, indentation, depth, refs, printer) => {
if (++depth > config.maxDepth) {

@@ -50,18 +45,5 @@ return '[' + collection.constructor.name + ']';

return (
collection.constructor.name +
SPACE +
'{' +
(0, _collections.printObjectProperties)(
convertCollectionToObject(collection),
config,
indentation,
depth,
refs,
printer) +
return collection.constructor.name + SPACE + '{' + (0, _collections.printObjectProperties)(convertCollectionToObject(collection), config, indentation, depth, refs, printer) + '}';
};
'}');
};exports.default =
{ serialize, test };
exports.default = { serialize, test };

@@ -1,41 +0,19 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.serialize = exports.test = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = exports.test = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var _markup = require('./lib/markup'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const ELEMENT_NODE = 1;

@@ -47,12 +25,5 @@ const TEXT_NODE = 3;

const testNode = (nodeType, name) =>
nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) ||
nodeType === TEXT_NODE && name === 'Text' ||
nodeType === COMMENT_NODE && name === 'Comment';
const testNode = (nodeType, name) => nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment';
const test = exports.test = val =>
val &&
val.constructor &&
val.constructor.name &&
testNode(val.nodeType, val.constructor.name);
const test = exports.test = val => val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name);

@@ -66,10 +37,3 @@ // Convert array of attribute objects to keys array and props object.

const serialize = exports.serialize = (
node,
config,
indentation,
depth,
refs,
printer) =>
{
const serialize = exports.serialize = (node, config, indentation, depth, refs, printer) => {
if (node.nodeType === TEXT_NODE) {

@@ -88,26 +52,5 @@ return (0, _markup.printText)(node.data, config);

return (0, _markup.printElement)(
type,
(0, _markup.printProps)(
Array.prototype.map.call(node.attributes, keysMapper).sort(),
Array.prototype.reduce.call(node.attributes, propsReducer, {}),
config,
indentation + config.indent,
depth,
refs,
printer),
return (0, _markup.printElement)(type, (0, _markup.printProps)(Array.prototype.map.call(node.attributes, keysMapper).sort(), Array.prototype.reduce.call(node.attributes, propsReducer, {}), config, indentation + config.indent, depth, refs, printer), (0, _markup.printChildren)(Array.prototype.slice.call(node.childNodes), config, indentation + config.indent, depth, refs, printer), config, indentation);
};
(0, _markup.printChildren)(
Array.prototype.slice.call(node.childNodes),
config,
indentation + config.indent,
depth,
refs,
printer),
config,
indentation);
};exports.default =
{ serialize, test };
exports.default = { serialize, test };

@@ -1,11 +0,8 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.serialize = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _collections = require('../collections');

@@ -21,5 +18,14 @@

*
*/const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
*/
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
const getImmutableName = name => 'Immutable.' + name;

@@ -30,26 +36,4 @@ const printAsLeaf = name => '[' + name + ']';

const printImmutableEntries = (
val,
config,
indentation,
depth,
refs,
printer,
type) =>
const printImmutableEntries = (val, config, indentation, depth, refs, printer, type) => ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '{' + (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) + '}';
++depth > config.maxDepth ?
printAsLeaf(getImmutableName(type)) :
getImmutableName(type) +
SPACE +
'{' +
(0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer) +
'}';
// Record has an entries method because it is a collection in immutable v3.

@@ -66,41 +50,14 @@ // Return an iterator for Immutable Record from version v3 or v4.

return { done: true };
} };
}
};
};
const printImmutableRecord = (
val,
config,
indentation,
depth,
refs,
printer) =>
{
const printImmutableRecord = (val, config, indentation, depth, refs, printer) => {
// _name property is defined only for an Immutable Record instance
// which was constructed with a second optional descriptive name arg
const name = getImmutableName(val._name || 'Record');
return ++depth > config.maxDepth ?
printAsLeaf(name) :
name +
SPACE +
'{' +
(0, _collections.printIteratorEntries)(
getRecordEntries(val),
config,
indentation,
depth,
refs,
printer) +
'}';
return ++depth > config.maxDepth ? printAsLeaf(name) : name + SPACE + '{' + (0, _collections.printIteratorEntries)(getRecordEntries(val), config, indentation, depth, refs, printer) + '}';
};
const printImmutableSeq = (
val,
config,
indentation,
depth,
refs,
printer) =>
{
const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
const name = getImmutableName('Seq');

@@ -113,118 +70,29 @@

if (val[IS_KEYED_SENTINEL]) {
return (
name +
SPACE +
'{' + (
// from Immutable collection of entries or from ECMAScript object
val._iter || val._object ?
(0, _collections.printIteratorEntries)(
val.entries(),
config,
indentation,
depth,
refs,
printer) :
LAZY) +
'}');
return name + SPACE + '{' + (
// from Immutable collection of entries or from ECMAScript object
val._iter || val._object ? (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) : LAZY) + '}';
}
return (
name +
SPACE +
'[' + (
val._iter || // from Immutable collection of values
val._array || // from ECMAScript array
val._collection || // from ECMAScript collection in immutable v4
val._iterable // from ECMAScript collection in immutable v3
? (0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer) :
LAZY) +
']');
return name + SPACE + '[' + (val._iter || // from Immutable collection of values
val._array || // from ECMAScript array
val._collection || // from ECMAScript collection in immutable v4
val._iterable // from ECMAScript collection in immutable v3
? (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) : LAZY) + ']';
};
const printImmutableValues = (
val,
config,
indentation,
depth,
refs,
printer,
type) =>
const printImmutableValues = (val, config, indentation, depth, refs, printer, type) => ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '[' + (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + ']';
++depth > config.maxDepth ?
printAsLeaf(getImmutableName(type)) :
getImmutableName(type) +
SPACE +
'[' +
(0, _collections.printIteratorValues)(
val.values(),
config,
indentation,
depth,
refs,
printer) +
']';
const serialize = exports.serialize = (
val,
config,
indentation,
depth,
refs,
printer) =>
{
const serialize = exports.serialize = (val, config, indentation, depth, refs, printer) => {
if (val[IS_MAP_SENTINEL]) {
return printImmutableEntries(
val,
config,
indentation,
depth,
refs,
printer,
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map');
return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map');
}
if (val[IS_LIST_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
'List');
return printImmutableValues(val, config, indentation, depth, refs, printer, 'List');
}
if (val[IS_SET_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set');
return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set');
}
if (val[IS_STACK_SENTINEL]) {
return printImmutableValues(
val,
config,
indentation,
depth,
refs,
printer,
'Stack');
return printImmutableValues(val, config, indentation, depth, refs, printer, 'Stack');
}

@@ -242,6 +110,4 @@

// when mock identity-obj-proxy returns the key as the value for any key.
const test = exports.test = val =>
val && (
val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);exports.default =
const test = exports.test = val => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
{ serialize, test };
exports.default = { serialize, test };

@@ -1,17 +0,18 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = escapeHTML;
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
escapeHTML; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/function escapeHTML(str) {return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');}
function escapeHTML(str) {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

@@ -1,14 +0,14 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = undefined;
var _escape_html = require('./escape_html');
var _escape_html2 = _interopRequireDefault(_escape_html);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _escape_html = require('./escape_html');var _escape_html2 = _interopRequireDefault(_escape_html);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
// Return empty string if keys is empty.

@@ -22,8 +22,8 @@ /**

*
*/const printProps = exports.printProps = (keys, props, config, indentation, depth, refs, printer) =>
{
*/
const printProps = exports.printProps = (keys, props, config, indentation, depth, refs, printer) => {
const indentationNext = indentation + config.indent;
const colors = config.colors;
return keys.
map(key => {
return keys.map(key => {
const value = props[key];

@@ -34,8 +34,3 @@ let printed = printer(value, config, indentationNext, depth, refs);

if (printed.indexOf('\n') !== -1) {
printed =
config.spacingOuter +
indentationNext +
printed +
config.spacingOuter +
indentation;
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
}

@@ -45,36 +40,9 @@ printed = '{' + printed + '}';

return (
config.spacingInner +
indentation +
colors.prop.open +
key +
colors.prop.close +
'=' +
colors.value.open +
printed +
colors.value.close);
}).
join('');
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
}).join('');
};
// Return empty string if children is empty.
const printChildren = exports.printChildren = (
children,
config,
indentation,
depth,
refs,
printer) =>
{
return children.
map(
child =>
config.spacingOuter +
indentation + (
typeof child === 'string' ?
printText(child, config) :
printer(child, config, indentation, depth, refs))).
join('');
const printChildren = exports.printChildren = (children, config, indentation, depth, refs, printer) => {
return children.map(child => config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs))).join('');
};

@@ -89,9 +57,3 @@

const commentColor = config.colors.comment;
return (
commentColor.open +
'<!--' +
(0, _escape_html2.default)(comment) +
'-->' +
commentColor.close);
return commentColor.open + '<!--' + (0, _escape_html2.default)(comment) + '-->' + commentColor.close;
};

@@ -103,33 +65,5 @@

// in a self-closing tagColor requires a second test of printedProps.
const printElement = exports.printElement = (
type,
printedProps,
printedChildren,
config,
indentation) =>
{
const printElement = exports.printElement = (type, printedProps, printedChildren, config, indentation) => {
const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type + (
printedProps &&
tagColor.close +
printedProps +
config.spacingOuter +
indentation +
tagColor.open) + (
printedChildren ?
'>' +
tagColor.close +
printedChildren +
config.spacingOuter +
indentation +
tagColor.open +
'</' +
type :
(printedProps && !config.min ? '' : ' ') + '/') +
'>' +
tagColor.close);
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
};

@@ -139,12 +73,3 @@

const tagColor = config.colors.tag;
return (
tagColor.open +
'<' +
type +
tagColor.close +
' …' +
tagColor.open +
' />' +
tagColor.close);
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
};

@@ -1,24 +0,26 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.serialize = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const elementSymbol = Symbol.for('react.element');
var _markup = require('./lib/markup'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const elementSymbol = Symbol.for('react.element');
// Given element.props.children, or subtree during recursive traversal,
// return flattened array of children.
const getChildren = function (arg) {let children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
const getChildren = function (arg) {
let children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (Array.isArray(arg)) {

@@ -44,39 +46,6 @@ arg.forEach(item => {

const serialize = exports.serialize = (
element,
config,
indentation,
depth,
refs,
printer) =>
const serialize = exports.serialize = (element, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? (0, _markup.printElementAsLeaf)(getType(element), config) : (0, _markup.printElement)(getType(element), (0, _markup.printProps)(Object.keys(element.props).filter(key => key !== 'children').sort(), element.props, config, indentation + config.indent, depth, refs, printer), (0, _markup.printChildren)(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
++depth > config.maxDepth ?
(0, _markup.printElementAsLeaf)(getType(element), config) :
(0, _markup.printElement)(
getType(element),
(0, _markup.printProps)(
Object.keys(element.props).
filter(key => key !== 'children').
sort(),
element.props,
config,
indentation + config.indent,
depth,
refs,
printer),
const test = exports.test = val => val && val.$$typeof === elementSymbol;
(0, _markup.printChildren)(
getChildren(element.props.children),
config,
indentation + config.indent,
depth,
refs,
printer),
config,
indentation);
const test = exports.test = val => val && val.$$typeof === elementSymbol;exports.default =
{ serialize, test };
exports.default = { serialize, test };

@@ -1,69 +0,29 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.serialize = undefined;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.test = exports.serialize = undefined;
var _markup = require('./lib/markup');
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const testSymbol = Symbol.for('react.test.json');
var _markup = require('./lib/markup'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/const testSymbol = Symbol.for('react.test.json');
const serialize = exports.serialize = (
object,
config,
indentation,
depth,
refs,
printer) =>
++depth > config.maxDepth ?
(0, _markup.printElementAsLeaf)(object.type, config) :
(0, _markup.printElement)(
object.type,
object.props ?
(0, _markup.printProps)(
Object.keys(object.props).sort(),
const serialize = exports.serialize = (object, config, indentation, depth, refs, printer) => ++depth > config.maxDepth ? (0, _markup.printElementAsLeaf)(object.type, config) : (0, _markup.printElement)(object.type, object.props ? (0, _markup.printProps)(Object.keys(object.props).sort(),
// Despite ternary expression, Flow 0.51.0 found incorrect error:
// undefined is incompatible with the expected param type of Object
// $FlowFixMe
object.props,
config,
indentation + config.indent,
depth,
refs,
printer) :
object.props, config, indentation + config.indent, depth, refs, printer) : '', object.children ? (0, _markup.printChildren)(object.children, config, indentation + config.indent, depth, refs, printer) : '', config, indentation);
'',
object.children ?
(0, _markup.printChildren)(
object.children,
config,
indentation + config.indent,
depth,
refs,
printer) :
const test = exports.test = val => val && val.$$typeof === testSymbol;
'',
config,
indentation);
const test = exports.test = val => val && val.$$typeof === testSymbol;exports.default =
{ serialize, test };
exports.default = { serialize, test };
{
"name": "pretty-format",
"version": "22.4.0",
"version": "22.4.3",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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