Comparing version 2.2.0 to 2.2.1
@@ -157,5 +157,17 @@ const ansiColors = { | ||
function quoteComplexKey(key) { | ||
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) { | ||
return key | ||
} | ||
return JSON.stringify(key) | ||
.replace(/'/g, "\\'") | ||
.replace(/\\"/g, '"') | ||
.replace(/(^"|"$)/g, "'") | ||
} | ||
export function inspectProperty([key, value], options) { | ||
options.truncate -= 2 | ||
if (typeof key !== 'string' && typeof key !== 'number') { | ||
if (typeof key === 'string') { | ||
key = quoteComplexKey(key) | ||
} else if (typeof key !== 'number') { | ||
key = `[${options.inspect(key, options)}]` | ||
@@ -162,0 +174,0 @@ } |
13
loupe.js
@@ -624,2 +624,11 @@ (function (global, factory) { | ||
} | ||
function quoteComplexKey(key) { | ||
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) { | ||
return key; | ||
} | ||
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"); | ||
} | ||
function inspectProperty(_ref2, options) { | ||
@@ -632,3 +641,5 @@ var _ref3 = _slicedToArray(_ref2, 2), | ||
if (typeof key !== 'string' && typeof key !== 'number') { | ||
if (typeof key === 'string') { | ||
key = quoteComplexKey(key); | ||
} else if (typeof key !== 'number') { | ||
key = "[".concat(options.inspect(key, options), "]"); | ||
@@ -635,0 +646,0 @@ } |
{ | ||
"name": "loupe", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Inspect utility for Node.js and browsers", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/chaijs/loupe", |
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
70072
1655