【文件属性】:
文件名称:is-in-browser:检测当前环境是否是浏览器
文件大小:164KB
文件格式:ZIP
更新时间:2021-05-23 10:29:35
nodejs javascript browser TypeScript
在浏览器中吗?
import isBrowser from "is-in-browser" ;
if ( isBrowser ) {
//...
}
更彻底地:
import { isJsDom , isNode , isBrowser } from "is-in-browser" ;
if ( isBrowser ) {
// you're in the browser
// jsdom considered in browser
}
if ( isJsDom ) {
// you're in the JSDom
}
if ( isNode ) {
// you're in the Node
}
普通JS
对于不使用Babel / ES6模块的用户
var isBrowser = require ( 'is-in-browser' ) . default
【文件预览】:
is-in-browser-main
----.babelrc(216B)
----package.json(2KB)
----readme.md(488B)
----.prettierrc(45B)
----LICENSE(1KB)
----package-lock.json(750KB)
----src()
--------test.ts(381B)
--------node.check.ts(293B)
--------index.ts(373B)
----.npmignore(45B)
----.eslintrc.js(297B)
----.gitignore(32B)
----.editorconfig(399B)