(code?: number)
| 40 | * In the terminal this exits the process; in the browser it navigates to "/". |
| 41 | */ |
| 42 | export function exit(code?: number): never { |
| 43 | if (isWeb) { |
| 44 | if (typeof window !== "undefined") { |
| 45 | window.location.href = "/"; |
| 46 | } |
| 47 | // Keep the never return type satisfied in TS |
| 48 | throw new Error(`exit(${code ?? 0})`); |
| 49 | } |
| 50 | process.exit(code ?? 0); |
| 51 | } |
| 52 | |
| 53 | // ─── stdin/stdout stubs ─────────────────────────────────────────────────────── |
| 54 |