Last active
March 22, 2024 15:32
-
-
Save selimhex/9dbc3caaae5121f577780371bae41af3 to your computer and use it in GitHub Desktop.
debugging helper for weird js frameworks (#lwcðŸ˜)
This file contains 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
prettyJson = (obj) => { | |
return JSON.stringify(obj, null, 2); | |
}; | |
log(obj, name = "", color = null, table = false) { | |
if (table) { | |
console.log(`%c${name}`, `color: ${color || "unset"}`); | |
console.table(obj); | |
return; | |
} | |
console.log(`%c${name}`, `color: ${color || "unset"}`, this.prettyJson(obj)); | |
} | |
/* | |
Example Usage: | |
this.log(result.setupTimeResult, 'setupTimeResult', "lime"); | |
this.log(result.setupTimeResult.elements, "setupTimeResult.elements", "orange", true); | |
this.log(this.xAxis, "xAxis", "darkorange", false); | |
this.log(heightsArr, 'heightsArr', 'black; background: red'); | |
this.log({ i: i, target: targetId, chosen: i === this.chosenBlob, t: e.type, dtl: e.detail }, "e", "lime"); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment