npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-useragent

v0.12.0

Published

An Ember addon for Fastboot-enabled userAgent parsing via UAParser.js.

Downloads

29,667

Readme

Ember UserAgent Build Status Ember Observer Score Download count all time npm

Ember UserAgent is an Ember Addon for UserAgent parsing via UAParser.js.

The userAgent service works in both browser & Fastboot environments and makes it easy to detect:

  • Device Type
  • Device Model
  • Browser
  • Operating System
  • Layout Engine
  • CPU architecture

Compatibility

  • Ember.js v3.8 or above
  • Ember CLI v2.13 or above
  • Node.js v8 or above

Installation

ember install ember-useragent

Usage

Ember UserAgent exposes a service and a template helper.

Service

import { inject as service } from '@ember/service';

export default class FooComponent extends Component {
  @service userAgent;
}
const userAgent = this.get('userAgent');

userAgent.get('browser.isChrome'); // Boolean
userAgent.get('engine.isWebKit'); // Boolean
userAgent.get('os.info'); // => { name: 'Ubuntu', version: '11.10' }
userAgent.get('device.info'); // => { model: 'iPhone 7', type: 'mobile', vendor: 'Apple'}

Helper

{{#if (user-agent "browser.isChrome")}}
  Chrome, here...
{{/if}}

Service Properties

The service exposes all of UAParser's functions, but also adds some properties for quick access.

| browser | device | engine | os | cpu | |------------------|-----------|----------|-----------|--------------| | info | info | info | info | architecture | | isChrome | isConsole | isWebKit | isAndroid | | | isChromeHeadless | isDesktop | | isIOS | | | isEdge | isMobile | | isLinux | | | isFirefox | isTablet | | isMacOS | | | isIE | | | isWindows | | | isSafari | | | | |

The service also exposes the userAgent property, which contains the user agent string. You can overwrite this property, if you want to force a certain user agent string. All of the properties described above will update in accordance.

Manual Usage

Ember UserAgent auto imports ua-parser-js into your application using ember-auto-import:

import UAParser from 'ua-parser-js';

Injection

Prior to 0.11.0, this addon generated an initializer in app/initializers/user-agent.js that injected the userAgent service across all controllers, components and routes. This does not happen in >=0.11.0.

You can restore this behavior by manually performing these implicit injections (see #42), however this is highly discouraged, as this feature is deprecated by the upcoming Ember v4.0. If you were relying on these implicit injections, you should instead refactor your code to explicitly inject the userAgent service.

Using UAParser.js

For more information on how to use UAParser.js, please refer to the documentation.