From 4b971649ab666b260341b16188411c37b8c9bbc4 Mon Sep 17 00:00:00 2001 From: Connum Date: Mon, 27 Nov 2023 01:36:49 +0100 Subject: [PATCH] better browser/node detection --- src/util.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 5439ee84..53476ea5 100644 --- a/src/util.js +++ b/src/util.js @@ -1,9 +1,16 @@ function isBrowser() { - return typeof window !== 'undefined'; + return ( + typeof window !== 'undefined' || + typeof WorkerGlobalScope !== 'undefined' + ); } function isNode() { - return typeof window === 'undefined'; + return ( + typeof window === 'undefined' && + typeof global === 'object' && + typeof process === 'object' + ); } function checkArgument(expression, message) {