Skip to content

Instantly share code, notes, and snippets.

@disintegrator
Last active November 10, 2023 15:13
Show Gist options
  • Save disintegrator/20f8664c81d8b20c7f50b2af43b7aabf to your computer and use it in GitHub Desktop.
Save disintegrator/20f8664c81d8b20c7f50b2af43b7aabf to your computer and use it in GitHub Desktop.
console.group and the `using` keyword
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