/
environment.ts
31 lines (19 loc) · 1.19 KB
/
environment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { noop } from './helpers';
export const IS_DENO_ENV = typeof Deno !== 'undefined';
export const IS_NODE_ENV =
!IS_DENO_ENV &&
typeof global !== 'undefined' &&
typeof require === 'function' &&
!!global.process &&
typeof __filename === 'string' &&
(!((global as any) as Window).origin || typeof ((global as any) as Window).origin !== 'string');
export const OS_PLATFORM = IS_NODE_ENV ? process.platform : IS_DENO_ENV ? Deno.build.os : '';
export const IS_WINDOWS_ENV = OS_PLATFORM === 'win32' || OS_PLATFORM === 'windows';
export const IS_CASE_SENSITIVE_FILE_NAMES = !IS_WINDOWS_ENV;
export const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
export const IS_WEB_WORKER_ENV = IS_BROWSER_ENV && typeof self !== 'undefined' && typeof (self as any).importScripts === 'function';
export const HAS_WEB_WORKER = IS_BROWSER_ENV && typeof Worker === 'function';
export const IS_FETCH_ENV = typeof fetch === 'function';
export const requireFunc = IS_NODE_ENV ? require : noop;
export const getCurrentDirectory: () => string = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : () => '/';
declare const Deno: any;