Created
June 28, 2019 11:26
-
-
Save mathieucaroff/6851b295c1e4bffafce362d0a1ae00f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Author
mathieucaroff
commented
Jun 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment