1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Updated Readme to include typescript import

This commit is contained in:
Alexander Cerutti 2019-01-11 23:41:59 +01:00 committed by GitHub
parent 3d63c268f4
commit e17180a6a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,14 +20,15 @@ The upcoming 2.0 version has drastically changed API. All available methods can
# Use cases # Use cases
First of all, require the library: First of all, require the library. This is a UMD Module, so it will work for AMD, Typescript and CommonJS module systems.
```javascript ```javascript
const bowser = require('bowser'); const Bowser = require('bowser'); // CommonJS
import Bowser = require('bowser'); // Typescript
``` ```
By default, `require('bowser')` requires the *ES5 version of files*, which By default, the exported version is the *ES5 transpiled version*, which **do not** include any polyfills.
**do not** include any polyfills.
In case you don't use your own `babel-polyfill` you may need to have pre-built bundle with all needed polyfills. In case you don't use your own `babel-polyfill` you may need to have pre-built bundle with all needed polyfills.
So, for you it's suitable to require bowser like this: `require('bowser/bundled')`. So, for you it's suitable to require bowser like this: `require('bowser/bundled')`.
@ -63,6 +64,7 @@ or
const browser = bowser.getParser(window.navigator.userAgent); const browser = bowser.getParser(window.navigator.userAgent);
impression.userTechData = browser.parse(); impression.userTechData = browser.parse();
console.log(impression.userTechData); console.log(impression.userTechData);
// outputs // outputs
{ {
browser: { browser: {