browser-or-node icon indicating copy to clipboard operation
browser-or-node copied to clipboard

Check where your code is running. In the browser or in node.js environment.

Results 7 browser-or-node issues
Sort by recently updated
recently updated
newest added

Fix for Jest tests with React Native, where `navigator.userAgent === undefined`.

Self explanatory! It would be useful for not breaking frameworks like react-native, that don't have userAgent in their navigator

https://github.com/flexdinesh/browser-or-node/blob/9875469e69b0dbc6a35e50b104495facf869bb4a/src/index.js#L18-L22 ```sh $ node Welcome to Node.js v21.1.0. Type ".help" for more information. > > isJsDom = ... (typeof window !== "undefined" && window.name === "nodejs") || ... (typeof navigator...

even using 2.1.1 logic, when i run it in node (alpine14), i get the following error: ``` (navigator.userAgent.includes("Node.js") || ^ TypeError: Cannot read property 'includes' of undefined ``` when i...

Some bundlers automatically polyfills global `Buffer` and `process` if they can detect it being used. it really bugs me soooo much. trying to import this via a cdn like: https://esm.sh/browser-or-node...

# Purpose It supports another JavaScript runtime, a rising star - [bun]. Shortly, I added a new variable, `isBun`, which detects if the `Bun` is defined and its property -...

This is another separate PR which adds support for an alternative, lightweight DOM emulator - [`happy-dom`] As per the official repository of `happy-dom` Discussions, there was a question added about...