var MAX_DEPTH = 20 | |
export var expandedLog = (obj: Record<string, unknown>, depth: number = 0) => { | |
var [[name, item]] = Object.entries(obj) | |
if (depth < MAX_DEPTH && typeof item === 'object' && item) { | |
var typeString = Object.prototype.toString.call(item) | |
var objType = typeString.replace(/\[object (.*)\]/, '$1') | |
console.group(`${name}: ${objType}`) | |
Object.entries(item).forEach(([key, value]: any) => { | |
log({ [key]: value }, depth + 1) | |
}) | |
console.groupEnd() | |
} else { | |
var itemString = `${item}` | |
if (typeof item === 'string') { | |
itemString = `"${itemString}"` | |
} | |
console.log(`${name}: ${itemString}`) | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.