@beenotung/tslib
Version:
utils library in Typescript
27 lines (26 loc) • 697 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWindow = getWindow;
exports.getGlobal = getGlobal;
exports.getWindowOrGlobal = getWindowOrGlobal;
function getWindow() {
if (typeof window === 'undefined') {
throw new Error('Not running in Window runtime');
}
return window;
}
function getGlobal() {
if (typeof global === 'undefined') {
throw new Error('Not running in NodeJS runtime');
}
return global;
}
function getWindowOrGlobal() {
if (typeof global !== 'undefined') {
return global;
}
if (typeof window !== 'undefined') {
return window;
}
throw new Error('unknown runtime');
}