From 200221e742560f9a155b53a087f5355a90381c40 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 20 Jul 2022 17:23:48 -0400 Subject: [PATCH] *Add more safety checks on window --- src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 75e7c6c..cfcb7d7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,12 +15,12 @@ const DHT_MODULE = "AQD1IgE4lTZkq1fqdoYGojKRNrSk0YQ_wrHbRtIiHDrnow"; let callModule: typeof callModuleModule, connectModule: typeof connectModuleModule; -if (window.document) { - callModule = callModuleKernel; - connectModule = connectModuleKernel; +if (typeof window !== "undefined" && window?.document) { + callModule = callModuleKernel; + connectModule = connectModuleKernel; } else { - callModule = callModuleModule; - connectModule = connectModuleModule; + callModule = callModuleModule; + connectModule = connectModuleModule; } export class DHT {