Wraps a synchronous operation with automatic group management. Automatically calls startGroup() before the operation and endGroup() after. Ensures cleanup even if the operation throws an error.
The return type of the wrapped function.
The group label for this operation.
The synchronous function to wrap.
If true, creates a collapsed group (default: true).
The return value of the wrapped function.
Rethrows any error thrown by the wrapped function.
export function withGroup<T>(label: string, fn: () => T, collapsed = true): T { startGroup(label, collapsed); try { return fn(); } finally { endGroup(); }} Copy
export function withGroup<T>(label: string, fn: () => T, collapsed = true): T { startGroup(label, collapsed); try { return fn(); } finally { endGroup(); }}
Wraps a synchronous operation with automatic group management. Automatically calls startGroup() before the operation and endGroup() after. Ensures cleanup even if the operation throws an error.