pretty-format
Advanced tools
Comparing version 30.0.0-alpha.2 to 30.0.0-alpha.3
@@ -69,7 +69,7 @@ /** | ||
theme: Required<{ | ||
readonly comment?: string | undefined; | ||
readonly content?: string | undefined; | ||
readonly prop?: string | undefined; | ||
readonly tag?: string | undefined; | ||
readonly value?: string | undefined; | ||
comment?: string | undefined; | ||
content?: string | undefined; | ||
prop?: string | undefined; | ||
tag?: string | undefined; | ||
value?: string | undefined; | ||
}>; | ||
@@ -76,0 +76,0 @@ }; |
@@ -216,3 +216,3 @@ /*! | ||
if (typeof val.toAsymmetricMatcher !== 'function') { | ||
throw new Error(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`); | ||
throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`); | ||
} | ||
@@ -250,5 +250,5 @@ return val.toAsymmetricMatcher(); | ||
const SPACE = ' '; | ||
const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap']; | ||
const OBJECT_NAMES = new Set(['DOMStringMap', 'NamedNodeMap']); | ||
const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/; | ||
const testName = name => OBJECT_NAMES.includes(name) || ARRAY_REGEXP.test(name); | ||
const testName = name => OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name); | ||
const test = val => val && val.constructor && !!val.constructor.name && testName(val.constructor.name); | ||
@@ -262,3 +262,3 @@ exports.test = test; | ||
} | ||
return (config.min ? '' : name + SPACE) + (OBJECT_NAMES.includes(name) ? `{${(0, _collections.printObjectProperties)(isNamedNodeMap(collection) ? Array.from(collection).reduce((props, attribute) => { | ||
return (config.min ? '' : name + SPACE) + (OBJECT_NAMES.has(name) ? `{${(0, _collections.printObjectProperties)(isNamedNodeMap(collection) ? [...collection].reduce((props, attribute) => { | ||
props[attribute.name] = attribute.value; | ||
@@ -268,3 +268,3 @@ return props; | ||
...collection | ||
}, config, indentation, depth, refs, printer)}}` : `[${(0, _collections.printListItems)(Array.from(collection), config, indentation, depth, refs, printer)}]`); | ||
}, config, indentation, depth, refs, printer)}}` : `[${(0, _collections.printListItems)([...collection], config, indentation, depth, refs, printer)}]`); | ||
}; | ||
@@ -340,3 +340,3 @@ exports.serialize = serialize; | ||
} | ||
return (0, _markup.printElement)(type, (0, _markup.printProps)(nodeIsFragment(node) ? [] : Array.from(node.attributes, attr => attr.name).sort(), nodeIsFragment(node) ? {} : Array.from(node.attributes).reduce((props, attribute) => { | ||
return (0, _markup.printElement)(type, (0, _markup.printProps)(nodeIsFragment(node) ? [] : Array.from(node.attributes, attr => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => { | ||
props[attribute.name] = attribute.value; | ||
@@ -609,3 +609,3 @@ return props; | ||
function escapeHTML(str) { | ||
return str.replace(/</g, '<').replace(/>/g, '>'); | ||
return str.replaceAll('<', '<').replaceAll('>', '>'); | ||
} | ||
@@ -807,3 +807,3 @@ | ||
if (escapeString) { | ||
return `"${val.replace(/"|\\/g, '\\$&')}"`; | ||
return `"${val.replaceAll(/"|\\/g, '\\$&')}"`; | ||
} | ||
@@ -832,3 +832,3 @@ return `"${val}"`; | ||
if (toStringed === '[object Date]') { | ||
return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val); | ||
return Number.isNaN(+val) ? 'Date { NaN }' : toISOString.call(val); | ||
} | ||
@@ -841,3 +841,3 @@ if (toStringed === '[object Error]') { | ||
// https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js | ||
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); | ||
return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&'); | ||
} | ||
@@ -860,3 +860,3 @@ return regExpToString.call(val); | ||
} | ||
refs = refs.slice(); | ||
refs = [...refs]; | ||
refs.push(val); | ||
@@ -894,3 +894,3 @@ const hitMaxDepth = ++depth > config.maxDepth; | ||
const indentationNext = indentation + config.indent; | ||
return indentationNext + str.replace(NEWLINE_REGEXP, `\n${indentationNext}`); | ||
return indentationNext + str.replaceAll(NEWLINE_REGEXP, `\n${indentationNext}`); | ||
}, { | ||
@@ -905,3 +905,3 @@ edgeSpacing: config.spacingOuter, | ||
if (typeof printed !== 'string') { | ||
throw new Error(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`); | ||
throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`); | ||
} | ||
@@ -911,6 +911,6 @@ return printed; | ||
function findPlugin(plugins, val) { | ||
for (let p = 0; p < plugins.length; p++) { | ||
for (const plugin of plugins) { | ||
try { | ||
if (plugins[p].test(val)) { | ||
return plugins[p]; | ||
if (plugin.test(val)) { | ||
return plugin; | ||
} | ||
@@ -952,4 +952,4 @@ } catch (error) { | ||
indent: 2, | ||
maxDepth: Infinity, | ||
maxWidth: Infinity, | ||
maxDepth: Number.POSITIVE_INFINITY, | ||
maxWidth: Number.POSITIVE_INFINITY, | ||
min: false, | ||
@@ -975,3 +975,3 @@ plugins: [], | ||
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 TypeError(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`); | ||
} | ||
@@ -1017,3 +1017,5 @@ } | ||
function createIndent(indent) { | ||
return new Array(indent + 1).join(' '); | ||
return Array.from({ | ||
length: indent + 1 | ||
}).join(' '); | ||
} | ||
@@ -1020,0 +1022,0 @@ |
{ | ||
"name": "pretty-format", | ||
"version": "30.0.0-alpha.2", | ||
"version": "30.0.0-alpha.3", | ||
"repository": { | ||
@@ -24,3 +24,3 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/schemas": "30.0.0-alpha.2", | ||
"@jest/schemas": "30.0.0-alpha.3", | ||
"ansi-styles": "^5.0.0", | ||
@@ -34,3 +34,3 @@ "react-is": "^18.0.0" | ||
"immutable": "^4.0.0", | ||
"jest-util": "30.0.0-alpha.2", | ||
"jest-util": "30.0.0-alpha.3", | ||
"react": "18.2.0", | ||
@@ -46,3 +46,3 @@ "react-dom": "18.2.0", | ||
}, | ||
"gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4" | ||
"gitHead": "e267aff33d105399f2134bad7c8f82285104f3da" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1118
60184
+ Added@jest/schemas@30.0.0-alpha.3(transitive)
+ Added@sinclair/typebox@0.32.35(transitive)
- Removed@jest/schemas@30.0.0-alpha.2(transitive)
- Removed@sinclair/typebox@0.31.28(transitive)
Updated@jest/schemas@30.0.0-alpha.3