Skip to content

Commit

Permalink
docs(README): cpu, userAgent and manual usage
Browse files Browse the repository at this point in the history
  • Loading branch information
buschtoens authored and willviles committed Aug 1, 2018
1 parent f7ce57a commit 9485feb
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,36 @@ 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.getDevice(); // => { model: 'iPhone 7', type: 'mobile', vendor: 'Apple'}

userAgent.get('device.info'); // => { model: 'iPhone 7', type: 'mobile', vendor: 'Apple'}
```

### Service Properties

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

| browser | device | engine | os | userAgent |
|------------------|-----------|----------|-----------|-----------|
| info | info | info | info | |
| isChrome | isConsole | isWebKit | isAndroid | |
| isChromeHeadless | isDesktop | | isIOS | |
| isEdge | isMobile | | isLinux | |
| isFirefox | isTablet | | isMacOS | |
| isIE | | | isWindows | |
| isSafari | | | isWindows | |
| 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 | | | isWindows | |

### Manual Usage
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.

There aren't many use cases for using it manually, but Ember UserAgent shims UAParser.js into your application. Access it in one of two ways.
### Manual Usage

Module import:
There aren't many use cases for using it manually, but Ember UserAgent shims UAParser.js into your application.
You can import it like any other module:

```js
import UAParser from 'ua-parser-js';
```

Or from the service:

```js
{
userAgent: service(),
UAParser: alias('userAgent.UAParser')
}
```

### Injection

By default, this addon will generate an initializer in `app/initializers/user-agent.js` that injects the `userAgent` service app-wide. If the `userAgent` property conflicts with other addons or you wish to use manual injection (`Ember.service.inject`) you can override this file.
Expand Down

0 comments on commit 9485feb

Please sign in to comment.