-
-
Save hallettj/16486e17dbcd3ce86955433c4f858555 to your computer and use it in GitHub Desktop.
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
function prettyPrint(x: unknown): string { | |
if (Array.isArray(x)) { | |
return "[" + x.map(prettyPrint).join(", ") + "]" | |
} | |
if (typeof x === "string") { | |
return `"${x}"` | |
} | |
if (typeof x === "number") { | |
return String(x) | |
} | |
return "etc." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment