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

  • 1.0.0-0-alpha.67b0ddcb
  • unpublished
  • 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.

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

Concept

The useragent module puts information about the browser into your model, and it also updates this information when the size of the browser changes etc.

  • UA parser: browser and device
  • Window: size & orientation
  • Media queries
  • Feature detection
  • Internet connectivity

Install

This project is still in alpha. To test alpha version check instructions in monorepo.

Setup

import {Controller} from 'cerebral'
import Useragent from 'cerebral-module-useragent'

const controller = Controller({
  modules: {
    useragent: Useragent({
      // Use CSS media queries to determine
      // custom sizes available in your model.
      // They will be toggle between true/false in your
      // model
      media: {
        small: '(min-width: 600px)',
        medium: '(min-width: 1024px)',
        large: '(min-width: 1440px)',
        portrait: '(orientation: portrait)'
      },

      // store all feature tests in model
      feature: true,

      parse: {
        // parse useragent.browser from ua string
        browser: true,
        // parse useragent.device from ua string
        device: true
      },

      // check the docs at: https://github.com/HubSpot/offline#advanced
      offline: {
        checkOnLoad: false,
        interceptRequests: true,
        reconnect: {
          initialDelay: 3,
          delay: 1.5
        },
        requests: false
      },

      // update window size on resize
      window: true
    })
  }
})

Grabbing details from useragent

The useragent module will populate your model on the given namespace. All you need to do in your view layer is to grab whatever data you need from it, for example media:

export default connect({
  media: 'useragent.media.*'
}, ...)

Keywords

FAQs

Package last updated on 06 Jan 2017

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