Last active
November 10, 2023 15:13
-
-
Save disintegrator/20f8664c81d8b20c7f50b2af43b7aabf to your computer and use it in GitHub Desktop.
console.group and the `using` keyword
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 logGroup(label: string) { | |
console.group(label) | |
return { | |
[Symbol.dispose]: () => { | |
console.groupEnd() | |
} | |
} | |
} | |
function demo() { | |
using _checks = logGroup("Running checks"); | |
console.log("Build completed") | |
{ | |
using _tests = logGroup("Testing") | |
console.log("Unit tests passed") | |
console.log("Visual regression tests passed") | |
} | |
console.log("Tarball created") | |
console.log("Uploaded artifacts") | |
} | |
demo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment