zax-device
TypeScript icon, indicating that this package has built-in type declarations

4.0.2 • Public • Published

Zax Device

support SSR & Miniprogram & Browser side

NPM version Build Status codecov code style: prettier

util module

Browsers support

IE / EdgeIE / Edge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari OperaOpera
IE8+ Edge+ last 10 versions last 10 versions last 2 versions last 2 versions last 2 versions

Install

npm i zax-device -S

usage

import ZaxDevice,{ isWechat, isAlipay, isToutiao, isDouyin, isApp, isMiniApp, isAndroid, isIOS, isClientSide, isServerSide, isWechatMiniApp, isAlipayMiniApp, isBytedanceMiniApp, isBaiduMiniApp } from 'zax-device'
let device = new ZaxDevice({
	ua: 'CUSTOM UA OR NULL',
	appMapping: {
		dax: 'WEBVIEW_FLAG'
	}
})

// client side
// or
import { device } from 'zax-device'

device.setAppMapping('dax', 'DAX_REGEX_FLAG') //
device.setUA(ctx.reqeust.header['user-agent']) // set server ua

isWechat() //
isWechat() //
isAlipay() //
isToutiao() //
isDouyin() //
isApp() //
isApp('douyin') // same as isDouyin()
isMiniApp() //
isAndroid() //
isIOS() //
isClientSide() //
isServerSide() //
isWechatMiniApp() //
isAlipayMiniApp() //
isBytedanceMiniApp() //
isBaiduMiniApp() //

//server side
isIOS(ctx.reqeust.header['user-agent'])

Docs

Test Case

Dependencies (0)

    Dev Dependencies (22)

    Package Sidebar

    Install

    npm i zax-device

    Weekly Downloads

    2

    Version

    4.0.2

    License

    MIT

    Unpacked Size

    95.5 kB

    Total Files

    34

    Last publish

    Collaborators

    • jsonchou