@dmail/inspect
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -333,25 +333,32 @@ 'use strict'; | ||
useNew = _ref.useNew; | ||
if (seen.indexOf(value) > -1) { | ||
return "Symbol.for('circular')"; | ||
} | ||
if (seen.indexOf(value) > -1) return "Symbol.for('circular')"; | ||
seen.push(value); | ||
var propertiesSource = ""; | ||
var propertyNames = Object.getOwnPropertyNames(value); | ||
var i = 0; | ||
var j = propertyNames.length; | ||
while (i < j) { | ||
var propertyName = propertyNames[i]; | ||
var propertySourceArray = []; | ||
Object.getOwnPropertyNames(value).forEach(function (propertyName) { | ||
var propertyNameAsNumber = parseInt(propertyName, 10); | ||
var propertyNameSource = nestedInspect(Number.isInteger(propertyNameAsNumber) ? propertyNameAsNumber : propertyName); | ||
var propertyValueSource = nestedInspect(value[propertyName], { | ||
seen: seen | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: propertyNameSource, | ||
valueSource: nestedInspect(value[propertyName], { | ||
seen: seen | ||
}) | ||
}); | ||
}); | ||
Object.getOwnPropertySymbols(value).forEach(function (symbol) { | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: "[".concat(nestedInspect(symbol), "]"), | ||
valueSource: nestedInspect(value[symbol], { | ||
seen: seen | ||
}) | ||
}); | ||
}); | ||
var propertiesSource = ""; | ||
propertySourceArray.forEach(function (_ref2, index) { | ||
var nameOrSymbolSource = _ref2.nameOrSymbolSource, | ||
valueSource = _ref2.valueSource; | ||
if (i === 0) { | ||
propertiesSource += "".concat(propertyNameSource, ": ").concat(propertyValueSource); | ||
if (index === 0) { | ||
propertiesSource += "".concat(nameOrSymbolSource, ": ").concat(valueSource); | ||
} else { | ||
propertiesSource += ",".concat(preNewLineAndIndentation("".concat(propertyNameSource, ": ").concat(propertyValueSource), { | ||
propertiesSource += ",".concat(preNewLineAndIndentation("".concat(nameOrSymbolSource, ": ").concat(valueSource), { | ||
depth: depth, | ||
@@ -362,6 +369,3 @@ indentUsingTab: indentUsingTab, | ||
} | ||
i++; | ||
} | ||
}); | ||
var objectSource; | ||
@@ -368,0 +372,0 @@ |
@@ -334,25 +334,32 @@ var __dmail_inspect__ = function (exports) { | ||
useNew = _ref.useNew; | ||
if (seen.indexOf(value) > -1) { | ||
return "Symbol.for('circular')"; | ||
} | ||
if (seen.indexOf(value) > -1) return "Symbol.for('circular')"; | ||
seen.push(value); | ||
var propertiesSource = ""; | ||
var propertyNames = Object.getOwnPropertyNames(value); | ||
var i = 0; | ||
var j = propertyNames.length; | ||
while (i < j) { | ||
var propertyName = propertyNames[i]; | ||
var propertySourceArray = []; | ||
Object.getOwnPropertyNames(value).forEach(function (propertyName) { | ||
var propertyNameAsNumber = parseInt(propertyName, 10); | ||
var propertyNameSource = nestedInspect(Number.isInteger(propertyNameAsNumber) ? propertyNameAsNumber : propertyName); | ||
var propertyValueSource = nestedInspect(value[propertyName], { | ||
seen: seen | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: propertyNameSource, | ||
valueSource: nestedInspect(value[propertyName], { | ||
seen: seen | ||
}) | ||
}); | ||
}); | ||
Object.getOwnPropertySymbols(value).forEach(function (symbol) { | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: "[".concat(nestedInspect(symbol), "]"), | ||
valueSource: nestedInspect(value[symbol], { | ||
seen: seen | ||
}) | ||
}); | ||
}); | ||
var propertiesSource = ""; | ||
propertySourceArray.forEach(function (_ref2, index) { | ||
var nameOrSymbolSource = _ref2.nameOrSymbolSource, | ||
valueSource = _ref2.valueSource; | ||
if (i === 0) { | ||
propertiesSource += "".concat(propertyNameSource, ": ").concat(propertyValueSource); | ||
if (index === 0) { | ||
propertiesSource += "".concat(nameOrSymbolSource, ": ").concat(valueSource); | ||
} else { | ||
propertiesSource += ",".concat(preNewLineAndIndentation("".concat(propertyNameSource, ": ").concat(propertyValueSource), { | ||
propertiesSource += ",".concat(preNewLineAndIndentation("".concat(nameOrSymbolSource, ": ").concat(valueSource), { | ||
depth: depth, | ||
@@ -363,6 +370,3 @@ indentUsingTab: indentUsingTab, | ||
} | ||
i++; | ||
} | ||
}); | ||
var objectSource; | ||
@@ -369,0 +373,0 @@ |
{ | ||
"name": "@dmail/inspect", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -17,14 +17,8 @@ import { preNewLineAndIndentation, wrapNewLineAndIndentation } from "./util.js" | ||
) => { | ||
if (seen.indexOf(value) > -1) { | ||
return "Symbol.for('circular')" | ||
} | ||
if (seen.indexOf(value) > -1) return "Symbol.for('circular')" | ||
seen.push(value) | ||
let propertiesSource = "" | ||
const propertyNames = Object.getOwnPropertyNames(value) | ||
let i = 0 | ||
const j = propertyNames.length | ||
while (i < j) { | ||
const propertyName = propertyNames[i] | ||
const propertySourceArray = [] | ||
Object.getOwnPropertyNames(value).forEach((propertyName) => { | ||
const propertyNameAsNumber = parseInt(propertyName, 10) | ||
@@ -34,16 +28,27 @@ const propertyNameSource = nestedInspect( | ||
) | ||
const propertyValueSource = nestedInspect(value[propertyName], { seen }) | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: propertyNameSource, | ||
valueSource: nestedInspect(value[propertyName], { seen }), | ||
}) | ||
}) | ||
Object.getOwnPropertySymbols(value).forEach((symbol) => { | ||
propertySourceArray.push({ | ||
nameOrSymbolSource: `[${nestedInspect(symbol)}]`, | ||
valueSource: nestedInspect(value[symbol], { seen }), | ||
}) | ||
}) | ||
if (i === 0) { | ||
propertiesSource += `${propertyNameSource}: ${propertyValueSource}` | ||
let propertiesSource = "" | ||
propertySourceArray.forEach(({ nameOrSymbolSource, valueSource }, index) => { | ||
if (index === 0) { | ||
propertiesSource += `${nameOrSymbolSource}: ${valueSource}` | ||
} else { | ||
propertiesSource += `,${preNewLineAndIndentation( | ||
`${propertyNameSource}: ${propertyValueSource}`, | ||
{ depth, indentUsingTab, indentSize }, | ||
)}` | ||
propertiesSource += `,${preNewLineAndIndentation(`${nameOrSymbolSource}: ${valueSource}`, { | ||
depth, | ||
indentUsingTab, | ||
indentSize, | ||
})}` | ||
} | ||
}) | ||
i++ | ||
} | ||
let objectSource | ||
@@ -50,0 +55,0 @@ if (propertiesSource.length) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
87265
1305