Skip to content

Commit

Permalink
better browser/node detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Connum committed Nov 27, 2023
1 parent 556086f commit 4b97164
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 4b97164

Please sign in to comment.