Socket
Book a DemoInstallSign in
Socket

ua-device-type

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ua-device-type

user agent based device type sniffer tablet||phone||tv||desktop

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
120
445.45%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

ua-device-type

User agent based device type sniffer tablet||mobile||desktop||tv. Based almost wholely on the matching code from the npm package express-device by rguerreiro

example


var deviceType = require('ua-device-type');

deviceType('Mozilla/5.0 "
  +"(Linux; Android 4.1.1; Nexus 7 Build/JRO03S) "
  +"AppleWebKit/535.19 (KHTML, like Gecko) "
  +"Chrome/18.0.1025.166 Safari/535.19') === "tablet"

// true

api

deviceType(user agent string, [optional options])

return values

String

  • "tablet"
  • "phone"
  • "tv"
  • "desktop"

optional options

options is an object

  • emptyUserAgentDeviceType
    • if no user agent is passed or the user agent is empty this option will be returned.
    • defaults to "desktop"
  • unknownUserAgentDeviceType
    • instead of "phone" if unknown the value if this option will be returned
    • defaults to "phone"
  • botUserAgentDeviceType
    • instead of "bot" the value of this option will be returned.

thanks

Special thanks to rguerreiro author of https://github.com/rguerreiro/express-device who tracked down the device matching code from https://github.com/bjankord/Categorizr

I needed to use this without using express. its a small lib so i bundled it up for all to enjoy.

FAQs

Package last updated on 22 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts