Skip to content

Commit 943adfb

Browse files
committed
Merge branch 'release/2.1.0' into production
2 parents 4ec19a2 + a890039 commit 943adfb

File tree

10 files changed

+119
-62
lines changed

10 files changed

+119
-62
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Bowser Changelog
22

3+
### 2.1.0 (January 24, 2019)
4+
- [ADD] Add new `Parser.getEngineName()` method (#288)
5+
- [ADD] Add detection of ChromeOS (#287)
6+
- [FIX] Fix README
7+
38
### 2.0.0 (January 19, 2019)
49
- [ADD] Support a non strict equality in `Parser.satisfies()` (#275)
510
- [ADD] Add Android versions names (#276)

CONTRIBUTING.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
# Contributing
22

3-
The project runs Git-flow, where the `master` branch is the development one and `production` is the production one.
3+
We're always open to pull requests or code reviews. Everyone can become a permanent contributor. Just ping @lancedikson in the issues or on Twitter ❤️
44

5-
In a nutshell, if you're about to propose a new feature with adding some totally new functionality to `bowser`, it's better to branch from `master` and make a PR pointing back to `master` as well.
6-
If it's a small hotfix, fix a typo in the docs or you've added support for a new browser/OS/platform/etc, then it's better to branch from `production` and make a PR pointing back to `production`.
7-
Following these simple rules will help to maintain the repo a lot! Thanks ❤️
5+
## Branches
6+
7+
The project runs Git-flow, where the `master` branch is for development and `production` is for production.
8+
9+
In a nutshell, if you are proposing a new feature that adds totally new functionality to `bowser`, it's better to branch from `master` and make a PR pointing back to `master` as well.
10+
11+
If it's a small hot-fix, an improvement to the docs, or added support for a new browser/OS/platform/etc, then it's better to branch from `production` and make a PR pointing back to `production`.
12+
13+
Following these simple rules will really help maintain the repo! Thanks ❤️
14+
15+
## Adding Tests
16+
17+
See the list in `test/acceptance/useragentstrings.yml` with example user agents and their expected `bowser` object.
18+
19+
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
20+
check if all tests are still passing.
21+
22+
## Testing
23+
24+
If you'd like to contribute a change to `bowser`, modify the files in `src/`, and run the following (you'll need `node` + `npm` installed):
25+
26+
``` sh
27+
$ npm install
28+
$ npm run build #build
29+
$ npm test #run tests
30+
$ npm run lint #check lint rules
31+
```

README.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ A browser detector. Because sometimes, there is no other way, and not even good
1313

1414
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.
1515

16-
_Please, note that this is an alpha version. Check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch for a stable version._
17-
1816
**Changes of version 2.0**
19-
The upcoming 2.0 version has drastically changed API. All available methods can be found in the `docs` folder from now on and on a webpage soon.
17+
18+
The version 2.0 has drastically changed API. All available methods can be found in the `docs` folder from now on and on a webpage soon.
19+
20+
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install [email protected]`._
21+
2022

2123
# Use cases
2224

23-
First of all, require the library. This is a UMD Module, so it will work for AMD, Typescript and CommonJS module systems.
25+
First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.
2426

2527
```javascript
2628
const Bowser = require("bowser"); // CommonJS
2729

28-
import * as Bowser from "bowser" // Typescript
30+
import * as Bowser from "bowser"; // TypeScript
31+
32+
import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInterop enabled)
2933
```
3034

3135
By default, the exported version is the *ES5 transpiled version*, which **do not** include any polyfills.
@@ -41,7 +45,7 @@ You may need to use the source files, so they will be available in the package a
4145
Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to do it with Bowser:
4246

4347
```javascript
44-
const browser = bowser.getParser(window.navigator.userAgent);
48+
const browser = Bowser.getParser(window.navigator.userAgent);
4549

4650
console.log(`The current browser name is "${browser.getBrowserName()}"`);
4751
// The current browser name is "Internet Explorer"
@@ -52,7 +56,7 @@ or
5256
```javascript
5357
const impression = new Impression();
5458

55-
const browser = bowser.getParser(window.navigator.userAgent);
59+
const browser = Bowser.getParser(window.navigator.userAgent);
5660
const browserInfo = browser.getBrowser();
5761
impression.brName = browserInfo.name;
5862
impression.brVer = browserInfo.version;
@@ -61,7 +65,7 @@ impression.brVer = browserInfo.version;
6165
or
6266

6367
```javascript
64-
const browser = bowser.getParser(window.navigator.userAgent);
68+
const browser = Bowser.getParser(window.navigator.userAgent);
6569
impression.userTechData = browser.parse();
6670
console.log(impression.userTechData);
6771

@@ -93,7 +97,7 @@ You could want to filter some particular browsers to provide any special support
9397
It could look like this:
9498

9599
```javascript
96-
const browser = bowser.getParser(window.navigator.userAgent);
100+
const browser = Bowser.getParser(window.navigator.userAgent);
97101
const isValidBrowser = browser.satisfies({
98102
// declare browsers per OS
99103
windows: {
@@ -128,25 +132,6 @@ Thus, you can define OS or platform specific rules and they will have more prior
128132

129133
More of API and possibilities you will find in the `docs` folder.
130134

131-
# Contributing
132-
133-
We're always open to pull requests or code reviews. Everyone can become a permanent contributor. Just ping @lancedikson in the issues or on Twitter ❤️
134-
135-
If you'd like to contribute a change to bowser, modify the files in `src/`, then run the following (you'll need node + npm installed):
136-
137-
``` sh
138-
$ npm install
139-
$ npm run build #build
140-
$ npm test #run tests
141-
$ npm run lint #check lint rules
142-
```
143-
144-
### Adding tests
145-
See the list in `test/acceptance/useragentstrings.yml` with example user agents and their expected bowser object.
146-
147-
Whenever you add support for new browsers or notice a bug / mismatch, please update the list and
148-
check if all tests are still passing.
149-
150135
### Similar Projects
151136
* [Kong](https://github.com/BigBadBleuCheese/Kong) - A C# port of Bowser.
152137

index.d.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare namespace Bowser {
1313
* @param {boolean} skipParsing
1414
*/
1515

16-
function getParser(UA: string, skipParsing?: boolean): Parser.Parser;
16+
function getParser(UA: string, skipParsing?: boolean): Parser.Parser;
1717

1818
/**
1919
* Creates a Parser instance and runs Parser.getResult immediately
@@ -26,28 +26,28 @@ declare namespace Bowser {
2626

2727
declare namespace Parser {
2828
class Parser {
29-
constructor(UA: string, skipParsing?: boolean);
29+
constructor(UA: string, skipParsing?: boolean);
3030

3131
/**
3232
* Get parsed browser object
3333
* @return {BrowserDetails} Browser's details
3434
*/
3535

36-
getBrowser(): BrowserDetails;
36+
getBrowser(): BrowserDetails;
3737

3838
/**
3939
* Get browser's name
4040
* @return {String} Browser's name or an empty string
4141
*/
4242

43-
getBrowserName(): string;
43+
getBrowserName(): string;
4444

4545
/**
4646
* Get browser's version
4747
* @return {String} version of browser
4848
*/
4949

50-
getBrowserVersion(): string;
50+
getBrowserVersion(): string;
5151

5252
/**
5353
* Get OS
@@ -60,57 +60,57 @@ declare namespace Parser {
6060
* // }
6161
*/
6262

63-
getOS(): OSDetails;
63+
getOS(): OSDetails;
6464

6565
/**
6666
* Get OS name
6767
* @param {Boolean} [toLowerCase] return lower-cased value
6868
* @return {String} name of the OS — macOS, Windows, Linux, etc.
6969
*/
7070

71-
getOSName(toLowerCase?: boolean): string;
71+
getOSName(toLowerCase?: boolean): string;
7272

7373
/**
7474
* Get OS version
7575
* @return {String} full version with dots ('10.11.12', '5.6', etc)
7676
*/
7777

78-
getOSVersion(): string;
78+
getOSVersion(): string;
7979

8080
/**
8181
* Get parsed platform
8282
* @returns {PlatformDetails}
8383
*/
8484

85-
getPlatform(): PlatformDetails;
85+
getPlatform(): PlatformDetails;
8686

8787
/**
8888
* Get platform name
8989
* @param {boolean} toLowerCase
9090
*/
9191

92-
getPlatformType(toLowerCase?: boolean): string;
92+
getPlatformType(toLowerCase?: boolean): string;
9393

9494
/**
9595
* Get parsed engine
9696
* @returns {EngineDetails}
9797
*/
9898

99-
getEngine(): EngineDetails;
99+
getEngine(): EngineDetails;
100100

101101
/**
102102
* Get parsed result
103103
* @return {ParsedResult}
104104
*/
105105

106-
getResult(): ParsedResult;
106+
getResult(): ParsedResult;
107107

108108
/**
109109
* Get UserAgent string of current Parser instance
110110
* @return {String} User-Agent String of the current <Parser> object
111111
*/
112112

113-
getUA(): string;
113+
getUA(): string;
114114

115115
/**
116116
* Is anything? Check if the browser is called "anything",
@@ -119,41 +119,41 @@ declare namespace Parser {
119119
* @returns {Boolean}
120120
*/
121121

122-
is(anything: any): boolean;
122+
is(anything: any): boolean;
123123

124124
/**
125125
* Parse full information about the browser
126126
*/
127127

128-
parse(): void;
128+
parse(): void;
129129

130130
/**
131131
* Get parsed browser object
132132
* @returns {BrowserDetails}
133133
*/
134134

135-
parseBrowser(): BrowserDetails;
135+
parseBrowser(): BrowserDetails;
136136

137137
/**
138138
* Get parsed engine
139139
* @returns {EngineDetails}
140140
*/
141141

142-
parseEngine(): EngineDetails;
142+
parseEngine(): EngineDetails;
143143

144144
/**
145145
* Parse OS and save it to this.parsedResult.os
146146
* @returns {OSDetails}
147147
*/
148148

149-
parseOS(): OSDetails;
149+
parseOS(): OSDetails;
150150

151151
/**
152152
* Get parsed platform
153153
* @returns {PlatformDetails}
154154
*/
155155

156-
parsePlatform(): PlatformDetails;
156+
parsePlatform(): PlatformDetails;
157157

158158
/**
159159
* Check if parsed browser matches certain conditions
@@ -174,15 +174,15 @@ declare namespace Parser {
174174
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
175175
*/
176176

177-
satisfies(checkTree: checkTree): boolean | undefined;
177+
satisfies(checkTree: checkTree): boolean | undefined;
178178

179179
/**
180180
* Check if any of the given values satifies `.is(anything)`
181181
* @param {string[]} anythings
182182
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
183183
*/
184184

185-
some(anythings: string[]): boolean | undefined;
185+
some(anythings: string[]): boolean | undefined;
186186

187187
/**
188188
* Test a UA string for a regexp
@@ -191,34 +191,34 @@ declare namespace Parser {
191191
*/
192192

193193
test(regex: RegExp): boolean;
194-
}
194+
}
195195

196196
interface ParsedResult {
197197
browser: BrowserDetails;
198198
os: OSDetails;
199199
platform: PlatformDetails;
200200
engine: EngineDetails;
201-
}
201+
}
202202

203203
interface Details {
204204
name?: string;
205205
version?: string;
206-
}
206+
}
207207

208208
interface OSDetails extends Details {
209209
versionName?: string;
210-
}
210+
}
211211

212212
interface PlatformDetails {
213213
type?: string;
214214
vendor?: string;
215215
model?: string;
216-
}
216+
}
217217

218218
type BrowserDetails = Details;
219219
type EngineDetails = Details;
220220

221-
interface checkTree {
221+
interface checkTree {
222222
[key: string]: any;
223223
}
224224
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bowser",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Lightweight browser detector",
55
"keywords": [
66
"browser",

src/parser-os.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,14 @@ export default [
144144
};
145145
},
146146
},
147+
148+
/* Chrome OS */
149+
{
150+
test: [/CrOS/],
151+
describe() {
152+
return {
153+
name: 'Chrome OS',
154+
};
155+
},
156+
},
147157
];

0 commit comments

Comments
 (0)