pretty-format
Advanced tools
Comparing version
@@ -20,2 +20,5 @@ 'use strict'; | ||
var _ansiStyles = require('ansi-styles');var _ansiStyles2 = _interopRequireDefault(_ansiStyles); | ||
@@ -36,23 +39,3 @@ | ||
* | ||
*/ | ||
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; | ||
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; | ||
*/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;const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; | ||
const NEWLINE_REGEXP = /\n/gi; | ||
@@ -94,7 +77,4 @@ | ||
return '[Function]'; | ||
} else if (val.name === '') { | ||
return '[Function anonymous]'; | ||
} else { | ||
return '[Function ' + val.name + ']'; | ||
} | ||
return '[Function ' + (val.name || 'anonymous') + ']'; | ||
} | ||
@@ -178,71 +158,39 @@ | ||
function printList( | ||
function printListItems( | ||
list, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
let body = ''; | ||
let result = ''; | ||
if (list.length) { | ||
body += edgeSpacing; | ||
result += config.spacingOuter; | ||
const innerIndent = prevIndent + indent; | ||
const indentationNext = indentation + config.indent; | ||
for (let i = 0; i < list.length; i++) { | ||
body += | ||
innerIndent + | ||
print( | ||
list[i], | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
result += | ||
indentationNext + print(list[i], config, indentationNext, depth, refs); | ||
if (i < list.length - 1) { | ||
body += ',' + spacing; | ||
result += ',' + config.spacingInner; | ||
} else if (!config.min) { | ||
result += ','; | ||
} | ||
} | ||
body += (min ? '' : ',') + edgeSpacing + prevIndent; | ||
result += config.spacingOuter + indentation; | ||
} | ||
return body; | ||
return result; | ||
} | ||
function printMap( | ||
function printMapEntries( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
@@ -254,41 +202,23 @@ let result = ''; | ||
if (!current.done) { | ||
result += edgeSpacing; | ||
result += config.spacingOuter; | ||
const innerIndent = prevIndent + indent; | ||
const indentationNext = indentation + config.indent; | ||
while (!current.done) { | ||
const key = print( | ||
const name = print( | ||
current.value[0], | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
config, | ||
indentationNext, | ||
depth, | ||
refs); | ||
const value = print( | ||
current.value[1], | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
config, | ||
indentationNext, | ||
depth, | ||
refs); | ||
result += innerIndent + key + ' => ' + value; | ||
result += indentationNext + name + ' => ' + value; | ||
@@ -298,7 +228,9 @@ current = iterator.next(); | ||
if (!current.done) { | ||
result += ',' + spacing; | ||
result += ',' + config.spacingInner; | ||
} else if (!config.min) { | ||
result += ','; | ||
} | ||
} | ||
result += (min ? '' : ',') + edgeSpacing + prevIndent; | ||
result += config.spacingOuter + indentation; | ||
} | ||
@@ -309,17 +241,8 @@ | ||
function printObject( | ||
function printObjectProperties( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
@@ -335,49 +258,21 @@ let result = ''; | ||
if (keys.length) { | ||
result += edgeSpacing; | ||
result += config.spacingOuter; | ||
const innerIndent = prevIndent + indent; | ||
const indentationNext = indentation + config.indent; | ||
for (let i = 0; i < keys.length; i++) { | ||
const key = keys[i]; | ||
const name = print( | ||
key, | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
const name = print(key, config, indentationNext, depth, refs); | ||
const value = print(val[key], config, indentationNext, depth, refs); | ||
const value = print( | ||
val[key], | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
result += indentationNext + name + ': ' + value; | ||
result += innerIndent + name + ': ' + value; | ||
if (i < keys.length - 1) { | ||
result += ',' + spacing; | ||
result += ',' + config.spacingInner; | ||
} else if (!config.min) { | ||
result += ','; | ||
} | ||
} | ||
result += (min ? '' : ',') + edgeSpacing + prevIndent; | ||
result += config.spacingOuter + indentation; | ||
} | ||
@@ -388,55 +283,33 @@ | ||
function printSet( | ||
function printSetValues( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
let result = ''; | ||
const iterator = val.entries(); | ||
const iterator = val.values(); | ||
let current = iterator.next(); | ||
if (!current.done) { | ||
result += edgeSpacing; | ||
result += config.spacingOuter; | ||
const innerIndent = prevIndent + indent; | ||
const indentationNext = indentation + config.indent; | ||
while (!current.done) { | ||
result += | ||
innerIndent + | ||
print( | ||
current.value[1], | ||
indent, | ||
innerIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
indentationNext + | ||
print(current.value, config, indentationNext, depth, refs); | ||
current = iterator.next(); | ||
if (!current.done) { | ||
result += ',' + spacing; | ||
result += ',' + config.spacingInner; | ||
} else if (!config.min) { | ||
result += ','; | ||
} | ||
} | ||
result += (min ? '' : ',') + edgeSpacing + prevIndent; | ||
result += config.spacingOuter + indentation; | ||
} | ||
@@ -449,29 +322,18 @@ | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
refs = refs.slice(); | ||
if (refs.indexOf(val) > -1) { | ||
if (refs.indexOf(val) !== -1) { | ||
return '[Circular]'; | ||
} else { | ||
refs.push(val); | ||
} | ||
refs = refs.slice(); | ||
refs.push(val); | ||
currentDepth++; | ||
const hitMaxDepth = ++depth > config.maxDepth; | ||
const min = config.min; | ||
const hitMaxDepth = currentDepth > maxDepth; | ||
if ( | ||
callToJSON && | ||
config.callToJSON && | ||
!hitMaxDepth && | ||
@@ -481,18 +343,3 @@ val.toJSON && | ||
{ | ||
return print( | ||
val.toJSON(), | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
return print(val.toJSON(), config, indentation, depth, refs); | ||
} | ||
@@ -502,5 +349,2 @@ | ||
if (toStringed === '[object Arguments]') { | ||
if (val.length === 0) { | ||
return 'Arguments []'; | ||
} | ||
return hitMaxDepth ? | ||
@@ -510,108 +354,29 @@ '[Arguments]' : | ||
'[' + | ||
printList( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) + | ||
printListItems(val, config, indentation, depth, refs) + | ||
']'; | ||
} else if (isToStringedArrayType(toStringed)) { | ||
if (val.length === 0) { | ||
return val.constructor.name + ' []'; | ||
} | ||
} | ||
if (isToStringedArrayType(toStringed)) { | ||
return hitMaxDepth ? | ||
'[Array]' : | ||
'[' + val.constructor.name + ']' : | ||
(min ? '' : val.constructor.name + ' ') + | ||
'[' + | ||
printList( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) + | ||
printListItems(val, config, indentation, depth, refs) + | ||
']'; | ||
} else if (toStringed === '[object Map]') { | ||
} | ||
if (toStringed === '[object Map]') { | ||
return hitMaxDepth ? | ||
'[Map]' : | ||
'Map {' + | ||
printMap( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) + | ||
'}'; | ||
} else if (toStringed === '[object Set]') { | ||
'Map {' + printMapEntries(val, config, indentation, depth, refs) + '}'; | ||
} | ||
if (toStringed === '[object Set]') { | ||
return hitMaxDepth ? | ||
'[Set]' : | ||
'Set {' + | ||
printSet( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) + | ||
'}'; | ||
'Set {' + printSetValues(val, config, indentation, depth, refs) + '}'; | ||
} | ||
return hitMaxDepth ? | ||
'[Object]' : | ||
(min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ') + | ||
'[' + (val.constructor ? val.constructor.name : 'Object') + ']' : | ||
(min ? '' : (val.constructor ? val.constructor.name : 'Object') + ' ') + | ||
'{' + | ||
printObject( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) + | ||
printObjectProperties(val, config, indentation, depth, refs) + | ||
'}'; | ||
@@ -623,47 +388,31 @@ } | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
function boundPrint(val) { | ||
return print( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
return print(val, config, indentation, depth, refs); | ||
} | ||
function boundIndent(str) { | ||
const indentation = prevIndent + indent; | ||
return indentation + str.replace(NEWLINE_REGEXP, '\n' + indentation); | ||
const indentationNext = indentation + config.indent; | ||
return ( | ||
indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext)); | ||
} | ||
const opts = { | ||
edgeSpacing, | ||
min, | ||
spacing }; | ||
edgeSpacing: config.spacingOuter, | ||
min: config.min, | ||
spacing: config.spacingInner }; | ||
const printed = plugin.print(val, boundPrint, boundIndent, opts, colors); | ||
const printed = plugin.print( | ||
val, | ||
boundPrint, | ||
boundIndent, | ||
opts, | ||
config.colors); | ||
if (typeof printed !== 'string') { | ||
@@ -689,38 +438,17 @@ throw new Error( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors) | ||
config, | ||
indentation, | ||
depth, | ||
refs) | ||
{ | ||
const plugin = findPlugin(plugins, val); | ||
const plugin = findPlugin(config.plugins, val); | ||
if (plugin !== null) { | ||
return printPlugin( | ||
plugin, | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
return printPlugin(plugin, val, config, indentation, depth, refs); | ||
} | ||
const basicResult = printBasicValue(val, printFunctionName, escapeRegex); | ||
const basicResult = printBasicValue( | ||
val, | ||
config.printFunctionName, | ||
config.escapeRegex); | ||
if (basicResult !== null) { | ||
@@ -730,21 +458,16 @@ return basicResult; | ||
return printComplexValue( | ||
val, | ||
indent, | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
refs, | ||
maxDepth, | ||
currentDepth, | ||
plugins, | ||
min, | ||
callToJSON, | ||
printFunctionName, | ||
escapeRegex, | ||
colors); | ||
return printComplexValue(val, config, indentation, depth, refs); | ||
} | ||
const DEFAULTS = { | ||
const DEFAULT_THEME = { | ||
comment: 'gray', | ||
content: 'reset', | ||
prop: 'yellow', | ||
tag: 'cyan', | ||
value: 'green' }; | ||
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME); | ||
const DEFAULT_OPTIONS = { | ||
callToJSON: true, | ||
@@ -758,14 +481,8 @@ escapeRegex: false, | ||
printFunctionName: true, | ||
theme: { | ||
comment: 'gray', | ||
content: 'reset', | ||
prop: 'yellow', | ||
tag: 'cyan', | ||
value: 'green' } }; | ||
theme: DEFAULT_THEME }; | ||
function validateOptions(opts) { | ||
Object.keys(opts).forEach(key => { | ||
if (!DEFAULTS.hasOwnProperty(key)) { | ||
function validateOptions(options) { | ||
Object.keys(options).forEach(key => { | ||
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) { | ||
throw new Error(`pretty-format: Unknown option "${key}".`); | ||
@@ -775,3 +492,3 @@ } | ||
if (opts.min && opts.indent !== undefined && opts.indent !== 0) { | ||
if (options.min && options.indent !== undefined && options.indent !== 0) { | ||
throw new Error( | ||
@@ -781,105 +498,97 @@ 'pretty-format: Options "min" and "indent" cannot be used together.'); | ||
} | ||
} | ||
function normalizeOptions(opts) { | ||
const result = {}; | ||
if (options.theme !== undefined) { | ||
if (options.theme === null) { | ||
throw new Error(`pretty-format: Option "theme" must not be null.`); | ||
} | ||
Object.keys(DEFAULTS).forEach( | ||
key => | ||
result[key] = opts.hasOwnProperty(key) ? | ||
key === 'theme' ? normalizeTheme(opts.theme) : opts[key] : | ||
DEFAULTS[key]); | ||
if (typeof options.theme !== 'object') { | ||
throw new Error( | ||
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`); | ||
if (result.min) { | ||
result.indent = 0; | ||
} | ||
} | ||
// $FlowFixMe the type cast below means YOU are responsible to verify the code above. | ||
return result; | ||
} | ||
function normalizeTheme(themeOption) { | ||
if (!themeOption) { | ||
throw new Error(`pretty-format: Option "theme" must not be null.`); | ||
} | ||
if (typeof themeOption !== 'object') { | ||
const getColorsHighlight = options => | ||
DEFAULT_THEME_KEYS.reduce((colors, 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') | ||
{ | ||
colors[key] = color; | ||
} else { | ||
throw new Error( | ||
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof themeOption}".`); | ||
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`); | ||
} | ||
return colors; | ||
}, {}); | ||
// Silently ignore any keys in `theme` that are not in defaults. | ||
const themeRefined = themeOption; | ||
const themeDefaults = DEFAULTS.theme; | ||
return Object.keys(themeDefaults).reduce((theme, key) => { | ||
theme[key] = Object.prototype.hasOwnProperty.call(themeOption, key) ? | ||
themeRefined[key] : | ||
themeDefaults[key]; | ||
return theme; | ||
}, {}); | ||
} | ||
const getColorsEmpty = () => | ||
DEFAULT_THEME_KEYS.reduce((colors, key) => { | ||
colors[key] = { close: '', open: '' }; | ||
return colors; | ||
}, {}); | ||
function createIndent(indent) { | ||
return new Array(indent + 1).join(' '); | ||
} | ||
const getPrintFunctionName = options => | ||
options && options.printFunctionName !== undefined ? | ||
options.printFunctionName : | ||
DEFAULT_OPTIONS.printFunctionName; | ||
function prettyFormat(val, initialOptions) { | ||
let opts; | ||
if (!initialOptions) { | ||
opts = DEFAULTS; | ||
} else { | ||
validateOptions(initialOptions); | ||
opts = normalizeOptions(initialOptions); | ||
} | ||
const getEscapeRegex = options => | ||
options && options.escapeRegex !== undefined ? | ||
options.escapeRegex : | ||
DEFAULT_OPTIONS.escapeRegex; | ||
const colors = { | ||
comment: { close: '', open: '' }, | ||
content: { close: '', open: '' }, | ||
prop: { close: '', open: '' }, | ||
tag: { close: '', open: '' }, | ||
value: { close: '', open: '' } }; | ||
const getConfig = options => ({ | ||
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), | ||
Object.keys(opts.theme).forEach(key => { | ||
if (opts.highlight) { | ||
const color = colors[key] = _ansiStyles2.default[opts.theme[key]]; | ||
if ( | ||
!color || | ||
typeof color.close !== 'string' || | ||
typeof color.open !== 'string') | ||
{ | ||
throw new Error( | ||
`pretty-format: Option "theme" has a key "${key}" whose value "${opts. | ||
theme[key]}" is undefined in ansi-styles.`); | ||
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, | ||
printFunctionName: getPrintFunctionName(options), | ||
spacingInner: options && options.min ? ' ' : '\n', | ||
spacingOuter: options && options.min ? '' : '\n' }); | ||
} | ||
} | ||
}); | ||
const prevIndent = ''; | ||
const currentDepth = 0; | ||
const spacing = opts.min ? ' ' : '\n'; | ||
const edgeSpacing = opts.min ? '' : '\n'; | ||
function createIndent(indent) { | ||
return new Array(indent + 1).join(' '); | ||
} | ||
if (opts && opts.plugins.length) { | ||
const plugin = findPlugin(opts.plugins, val); | ||
if (plugin !== null) { | ||
return printPlugin( | ||
plugin, | ||
val, | ||
createIndent(opts.indent), | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
[], | ||
opts.maxDepth, | ||
currentDepth, | ||
opts.plugins, | ||
opts.min, | ||
opts.callToJSON, | ||
opts.printFunctionName, | ||
opts.escapeRegex, | ||
colors); | ||
function prettyFormat(val, options) { | ||
if (options) { | ||
validateOptions(options); | ||
if (options.plugins) { | ||
const plugin = findPlugin(options.plugins, val); | ||
if (plugin !== null) { | ||
return printPlugin(plugin, val, getConfig(options), '', 0, []); | ||
} | ||
} | ||
@@ -890,4 +599,4 @@ } | ||
val, | ||
opts.printFunctionName, | ||
opts.escapeRegex); | ||
getPrintFunctionName(options), | ||
getEscapeRegex(options)); | ||
@@ -898,18 +607,3 @@ if (basicResult !== null) { | ||
return printComplexValue( | ||
val, | ||
createIndent(opts.indent), | ||
prevIndent, | ||
spacing, | ||
edgeSpacing, | ||
[], | ||
opts.maxDepth, | ||
currentDepth, | ||
opts.plugins, | ||
opts.min, | ||
opts.callToJSON, | ||
opts.printFunctionName, | ||
opts.escapeRegex, | ||
colors); | ||
return printComplexValue(val, getConfig(options), '', 0, []); | ||
} | ||
@@ -916,0 +610,0 @@ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -27,3 +27,3 @@ | ||
* | ||
*/const SPACE = ' ';class ArrayContaining extends Array {}class ObjectContaining extends Object {}const print = (val, print, | ||
*/const SPACE = ' ';class ArrayContaining extends Array {}class ObjectContaining extends Object {}const print = exports.print = (val, print, | ||
indent, | ||
@@ -60,4 +60,5 @@ opts, | ||
const test = object => object && object.$$typeof === asymmetricMatcher; | ||
const test = exports.test = object => | ||
object && object.$$typeof === asymmetricMatcher;exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -50,7 +50,7 @@ | ||
* | ||
*/const test = value => typeof value === 'string' && value.match((0, _ansiRegex2.default)());const print = (val, print, indent, | ||
*/const test = exports.test = value => typeof value === 'string' && value.match((0, _ansiRegex2.default)());const print = exports.print = (val, print, indent, | ||
opts, | ||
colors) => | ||
print(toHumanReadableAnsi(val)); | ||
print(toHumanReadableAnsi(val));exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -44,3 +44,3 @@ | ||
const HTML_ELEMENT_REGEXP = /(HTML\w*?Element)|Text|Comment/; | ||
const test = isHTMLElement; | ||
const test = exports.test = isHTMLElement; | ||
@@ -97,3 +97,3 @@ function isHTMLElement(value) { | ||
const print = ( | ||
const print = exports.print = ( | ||
element, | ||
@@ -158,4 +158,4 @@ print, | ||
return result; | ||
}; | ||
};exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,7 +27,7 @@ | ||
* | ||
*/const IS_LIST = '@@__IMMUTABLE_LIST__@@';const test = maybeList => !!(maybeList && maybeList[IS_LIST]);const print = (val, print, indent, | ||
*/const IS_LIST = '@@__IMMUTABLE_LIST__@@';const test = exports.test = maybeList => !!(maybeList && maybeList[IS_LIST]);const print = exports.print = (val, print, indent, | ||
opts, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'List', false); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'List', false);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,3 +27,3 @@ | ||
* | ||
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeMap => !!(maybeMap && maybeMap[IS_MAP] && !maybeMap[IS_ORDERED]);const print = (val, | ||
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = exports.test = maybeMap => !!(maybeMap && maybeMap[IS_MAP] && !maybeMap[IS_ORDERED]);const print = exports.print = (val, | ||
print, | ||
@@ -33,4 +33,4 @@ indent, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Map', true); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Map', true);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,3 +27,3 @@ | ||
* | ||
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeOrderedMap => maybeOrderedMap && maybeOrderedMap[IS_MAP] && maybeOrderedMap[IS_ORDERED];const print = (val, | ||
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = exports.test = maybeOrderedMap => maybeOrderedMap && maybeOrderedMap[IS_MAP] && maybeOrderedMap[IS_ORDERED];const print = exports.print = (val, | ||
print, | ||
@@ -33,4 +33,4 @@ indent, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'OrderedMap', true); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'OrderedMap', true);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,3 +27,3 @@ | ||
* | ||
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeOrderedSet => maybeOrderedSet && maybeOrderedSet[IS_SET] && maybeOrderedSet[IS_ORDERED];const print = (val, | ||
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = exports.test = maybeOrderedSet => maybeOrderedSet && maybeOrderedSet[IS_SET] && maybeOrderedSet[IS_ORDERED];const print = exports.print = (val, | ||
print, | ||
@@ -33,4 +33,4 @@ indent, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'OrderedSet', false); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'OrderedSet', false);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,12 +17,12 @@ | ||
var _immutable_ordered_map = require('./immutable_ordered_map');var _immutable_ordered_map2 = _interopRequireDefault(_immutable_ordered_map); | ||
var _immutable_record = require('./immutable_record');var _immutable_record2 = _interopRequireDefault(_immutable_record);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
var _immutable_record = require('./immutable_record');var _immutable_record2 = _interopRequireDefault(_immutable_record);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}exports.default = | ||
module.exports = [_immutable_list2.default, _immutable_set2.default, _immutable_map2.default, _immutable_stack2.default, _immutable_ordered_set2.default, _immutable_ordered_map2.default, _immutable_record2.default]; /** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
*/ | ||
[_immutable_list2.default, _immutable_set2.default, _immutable_map2.default, _immutable_stack2.default, _immutable_ordered_set2.default, _immutable_ordered_map2.default, _immutable_record2.default]; /** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
*/ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,7 +27,8 @@ | ||
* | ||
*/const IS_RECORD = '@@__IMMUTABLE_RECORD__@@';const test = maybeRecord => !!(maybeRecord && maybeRecord[IS_RECORD]);const print = (val, print, indent, | ||
*/const IS_RECORD = '@@__IMMUTABLE_RECORD__@@';const test = exports.test = maybeRecord => !!(maybeRecord && maybeRecord[IS_RECORD]);const print = exports.print = (val, print, | ||
indent, | ||
opts, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Record', true); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Record', true);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,3 +27,3 @@ | ||
* | ||
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeSet => !!(maybeSet && maybeSet[IS_SET] && !maybeSet[IS_ORDERED]);const print = (val, | ||
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = exports.test = maybeSet => !!(maybeSet && maybeSet[IS_SET] && !maybeSet[IS_ORDERED]);const print = exports.print = (val, | ||
print, | ||
@@ -33,4 +33,4 @@ indent, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Set', false); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Set', false);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.print = exports.test = undefined; | ||
@@ -27,7 +27,7 @@ | ||
* | ||
*/const IS_STACK = '@@__IMMUTABLE_STACK__@@';const test = maybeStack => !!(maybeStack && maybeStack[IS_STACK]);const print = (val, print, indent, | ||
*/const IS_STACK = '@@__IMMUTABLE_STACK__@@';const test = exports.test = maybeStack => !!(maybeStack && maybeStack[IS_STACK]);const print = exports.print = (val, print, indent, | ||
opts, | ||
colors) => | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Stack', false); | ||
(0, _print_immutable2.default)(val, print, indent, opts, colors, 'Stack', false);exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,15 +0,19 @@ | ||
'use strict'; /** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
*/ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default = | ||
function escapeHTML(str) { | ||
return str.replace(/</g, '<').replace(/>/g, '>'); | ||
} | ||
module.exports = escapeHTML; | ||
escapeHTML; /** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* | ||
*/function escapeHTML(str) {return str.replace(/</g, '<').replace(/>/g, '>');} |
@@ -1,2 +0,2 @@ | ||
'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | ||
@@ -63,4 +63,4 @@ | ||
}; | ||
};exports.default = | ||
module.exports = printImmutable; | ||
printImmutable; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.print = undefined; | ||
@@ -76,3 +76,3 @@ | ||
const print = ( | ||
const print = exports.print = ( | ||
element, | ||
@@ -131,5 +131,5 @@ print, | ||
/* eslint-disable flowtype/no-weak-types */ | ||
const test = object => object && object.$$typeof === reactElement; | ||
/* eslint-enable flowtype/no-weak-types */ | ||
const test = exports.test = object => object && object.$$typeof === reactElement; | ||
/* eslint-enable flowtype/no-weak-types */exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.test = exports.print = undefined; | ||
@@ -72,3 +72,3 @@ | ||
const print = ( | ||
const print = exports.print = ( | ||
instance, | ||
@@ -117,5 +117,5 @@ print, | ||
const test = object => | ||
object && object.$$typeof === reactTestInstance; | ||
const test = exports.test = object => | ||
object && object.$$typeof === reactTestInstance;exports.default = | ||
module.exports = { print, test }; | ||
{ print, test }; |
{ | ||
"name": "pretty-format", | ||
"version": "20.1.0-delta.2", | ||
"version": "20.1.0-delta.3", | ||
"repository": { | ||
@@ -11,2 +11,3 @@ "type": "git", | ||
"main": "build/index.js", | ||
"browser": "build-es5/index.js", | ||
"author": "James Kyle <me@thejameskyle.com>", | ||
@@ -13,0 +14,0 @@ "dependencies": { |
428013
30.7%22
4.76%5338
106.18%