mirror of
https://github.com/danbulant/jose
synced 2026-05-25 04:51:47 +00:00
27 lines
725 B
JavaScript
27 lines
725 B
JavaScript
function getGlobal() {
|
|
if (typeof globalThis !== 'undefined')
|
|
return globalThis;
|
|
if (typeof self !== 'undefined')
|
|
return self;
|
|
if (typeof window !== 'undefined')
|
|
return window;
|
|
throw new Error('unable to locate global object');
|
|
}
|
|
export default getGlobal();
|
|
export function isCloudflareWorkers() {
|
|
try {
|
|
return getGlobal().WebSocketPair !== undefined;
|
|
}
|
|
catch (_a) {
|
|
return false;
|
|
}
|
|
}
|
|
export function isNodeJs() {
|
|
var _a, _b;
|
|
try {
|
|
return ((_b = (_a = getGlobal().process) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.node) !== undefined;
|
|
}
|
|
catch (_c) {
|
|
return false;
|
|
}
|
|
}
|