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

cerebral-module-useragent

Package Overview
Dependencies
Maintainers
4
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cerebral-module-useragent

Adds useragent specs to your cerebral state model

  • 0.10.21
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
4
Weekly downloads
 
Created
Source

cerebral-module-useragent

A Cerebral module for everything user agent.

This package is compatible with Cerebral 1.x. The current cerebral-module-useragent package for Cerebral 2 has moved to the Cerebral Monorepo.

NPM version Commitizen friendly Semantic Release js-standard-style Discord

cerebral-view-react

React view package for Cerebral

How to use

Go to http://www.cerebraljs.com/documentation/cerebral-module-useragent

User agent parser

I am using the ua-parser-js package to parse navigator.userAgent. Currently only the browser, device and OS parts are stored in the model, because I didn't see any use for cpu and engine.

Window

The window resize event is just slightly throttled using requestAnimationFrame(). I might make this configurable to use a stronger throttle timeout if it proofs to be too resource hungry.

Media queries

The media queries are tested with matchMedia() so you should be able to use any valid CSS media query.

Feature detection

I am using the feature.js package to detect browser features. Please checkout the website to see a list of all supported feature tests.

You can also only store certain test results in the model or define your own tests.

const useragent = Useragent({
  feature: {
    touch: true,
    serviceWorker: true,
    getUserMedia: () => !!navigator.getUserMedia
  }
})

All tests from feature.js are executed even if you set the feature option to false. This is a limitation of the library.

Network detection

I am using the offline-js package to detect internet connectivity. The application is initially assumed to be online.

Contribute

Fork repo

  • npm install
  • cd demo and npm install
  • npm start runs the demo which is currently used for testing
  • npm lint lint with JavaScript Standard Style
  • npm run build compiles es6 to es5

No tests yet. Feel free to issue a pull request if you want this.

Keywords

FAQs

Package last updated on 27 Oct 2016

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