Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compoundjs-device-detective

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compoundjs-device-detective

## What it does

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#Compoundjs Device Detective

What it does

Device Detective is a featherweight CompoundJs module which determines whether a user agent is a phone, tablet, desktop, text browser (e.g., Lynx), or a search engine crawler (e.g., GoogleBot, BingBot, Baiduspider, etc.). And it makes this info easy to get at.

Like all UA sniffers, Device Detective relies on a handful of regular expressions to determine what sort of device has issued the HTTP request. Device Detective implements MDN recommendations for detecting mobiles, and allows the developer to choose whether to use the distinction between tablets and smaller mobile devices, which is available via the UA header (it's not recommended for the general use case).

Installation

Simply cd to your project's root directory and issue the following command.

npm install compoundjs-device-detective
//environment.js

...
var device          = require('compoundjs-device-detective');
app.locals.device     = compound.controllerExtensions.device        = device;
...

//your_controller.js

load('application');

action('main', function (req, res){
...
device.isDesktop(req ) // true|false
...
});

detect( req ) 
=>  {
    "phone" : [boolean],
    "tablet" : [boolean],
    "mobile" : [boolean],
    "desktop" : [boolean],
    "lynx" : [boolean],
    "crawler" : [boolean]
    }
              
isPhone( req )   =>   [boolean]
isTablet( req )  =>   [boolean]
isMobile( req )  =>   [boolean]
isDesktop( req ) =>   [boolean]    
isLynx( req )    =>   [boolean]
isCrawler( req ) =>   [boolean]

Keywords

FAQs

Package last updated on 30 Jul 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc