@trifrost/core
Version:
Blazingly fast, runtime-agnostic server framework for modern edge and node environments
22 lines (21 loc) • 706 B
JavaScript
import { WorkerdRuntime } from './Workerd/Runtime';
/**
* Runtime detector function which returns a promise for the current runtime
*/
export async function getRuntime() {
/* Workerd */
if (typeof globalThis.WorkerGlobalScope !== 'undefined') {
return new WorkerdRuntime();
}
/* Bun */
if (typeof Bun !== 'undefined') {
const { BunRuntime } = await import('./Bun/Runtime.js');
return new BunRuntime();
}
/* NodeJS */
if (process?.versions?.node) {
const { NodeRuntime } = await import('./Node/Runtime.js');
return new NodeRuntime();
}
throw new Error('TriFrost: No supported runtime detected. Please specify a runtime.');
}