@trifrost/core
Version:
Blazingly fast, runtime-agnostic server framework for modern edge and node environments
25 lines (24 loc) • 815 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRuntime = getRuntime;
const Runtime_1 = require("./Workerd/Runtime");
/**
* Runtime detector function which returns a promise for the current runtime
*/
async function getRuntime() {
/* Workerd */
if (typeof globalThis.WorkerGlobalScope !== 'undefined') {
return new Runtime_1.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.');
}