Explorar o código

add browser-utils

Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
4d68492df3
Modificáronse 2 ficheiros con 8 adicións e 0 borrados
  1. 1 0
      packages/core/src/index.js
  2. 7 0
      packages/core/src/utils/browser-utils.ts

+ 1 - 0
packages/core/src/index.js

@@ -18,4 +18,5 @@ export * from './plugin/service/tag-cache-manager';
 export * from './models/devided-page-path';
 export * from './service/localstorage-manager';
 export * from './utils/basic-interceptor';
+export * from './utils/browser-utils';
 export * from './utils/mongoose-utils';

+ 7 - 0
packages/core/src/utils/browser-utils.ts

@@ -0,0 +1,7 @@
+export const isClient = (): boolean => {
+  return (typeof window !== 'undefined') || (typeof navigator !== 'undefined' && navigator.webdriver);
+};
+
+export const isServer = (): boolean => {
+  return !isClient();
+};