Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

is-browser

v0.88.2arrow_drop_down
v0.88.2
v0.86.0
v0.85.0
v0.84.0
STATUS
Passing
DOWNLOADS
25,165
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
3 months ago
SIZE
25 KB
1 contributor
Install is-browser as a package?
Copied
npm i @bit/semantic-org.semantic-ui-react.utils.is-browser
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
isBrowser.js
10 Lines(6 sloc)
1
2
3
4
5
6
7
8
9
10
11
import _ from 'lodash'

const hasDocument = typeof document === 'object' && document !== null
const hasWindow = typeof window === 'object' && window !== null && window.self === window

// eslint-disable-next-line no-confusing-arrow
const isBrowser = () =>
  !_.isNil(isBrowser.override) ? isBrowser.override : hasDocument && hasWindow

export default isBrowser