mirror of
https://github.com/lancedikson/bowser
synced 2026-01-21 08:10:26 +00:00
Compare commits
301 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f51d8bce8 | ||
|
|
1df8838756 | ||
|
|
eef8480944 | ||
|
|
514510d847 | ||
|
|
4a6dacca08 | ||
|
|
be90a00e37 | ||
|
|
f7d2c0693c | ||
|
|
771dfb2dfe | ||
|
|
bd5cb7186c | ||
|
|
2b5ee5de8c | ||
|
|
a4d0b828e4 | ||
|
|
5bfd3e9e6c | ||
|
|
3c25806efe | ||
|
|
8ac2f6a1ec | ||
|
|
20fc037785 | ||
|
|
afc0fbf131 | ||
|
|
e0ee0e7baf | ||
|
|
8c489bd98b | ||
|
|
5bab4ee97d | ||
|
|
16c9f22546 | ||
|
|
327e6f5e51 | ||
|
|
0626bf8c8c | ||
|
|
94ab87ec0e | ||
|
|
07462efb6a | ||
|
|
f8fcea59e7 | ||
|
|
4481f5aab3 | ||
|
|
0c7380dbf9 | ||
|
|
bb8f94efcd | ||
|
|
29222b2fcf | ||
|
|
69bc6c2dbf | ||
|
|
9c1588a43e | ||
|
|
fefa53ad95 | ||
|
|
efb8e612a5 | ||
|
|
b86bce16af | ||
|
|
f09411489c | ||
|
|
e188e8aa73 | ||
|
|
1d64ecab12 | ||
|
|
5b11ac25ca | ||
|
|
53d54e248c | ||
|
|
b7c67e9094 | ||
|
|
b2383edfcd | ||
|
|
e431acf578 | ||
|
|
c504b110bb | ||
|
|
a6317d24ca | ||
|
|
24dab5f699 | ||
|
|
444c54a726 | ||
|
|
bf24d05d5e | ||
|
|
1e4c408452 | ||
|
|
0deba6685e | ||
|
|
a9c4677c86 | ||
|
|
53d18c8994 | ||
|
|
d5fe5657d1 | ||
|
|
c925fd755b | ||
|
|
867992471a | ||
|
|
1bde6c6c7e | ||
|
|
33d6f9a37d | ||
|
|
d1a6532d82 | ||
|
|
cc546cfb44 | ||
|
|
77f394c8e7 | ||
|
|
7adb0017dd | ||
|
|
a7bc7110e2 | ||
|
|
7a273350d9 | ||
|
|
3d167b278e | ||
|
|
41c30ec722 | ||
|
|
ba8f7d8a54 | ||
|
|
725de76e14 | ||
|
|
9edfabf98a | ||
|
|
3813d92a55 | ||
|
|
dbb433945a | ||
|
|
d3d710d158 | ||
|
|
9007a9e393 | ||
|
|
8fe4b98a56 | ||
|
|
57e6d2b5d3 | ||
|
|
98f32dfbf5 | ||
|
|
a61817abb1 | ||
|
|
538ee8fe0e | ||
|
|
cb242c0242 | ||
|
|
a7cff0b965 | ||
|
|
efa7801204 | ||
|
|
a990b6b2f6 | ||
|
|
13ab38aebd | ||
|
|
437b6536ca | ||
|
|
c83b241238 | ||
|
|
743050f42e | ||
|
|
a1cbad9455 | ||
|
|
6add52d49c | ||
|
|
0a790b84b8 | ||
|
|
433955ac68 | ||
|
|
9af50fd1c7 | ||
|
|
214cdb52bc | ||
|
|
07fcffe812 | ||
|
|
a8aa331c39 | ||
|
|
a4a1a86d25 | ||
|
|
be8860b731 | ||
|
|
5131706495 | ||
|
|
db8e9d4417 | ||
|
|
341dd8ef40 | ||
|
|
2132446318 | ||
|
|
50f5a73386 | ||
|
|
e575388f48 | ||
|
|
b0b505fbe2 | ||
|
|
48866a119e | ||
|
|
a523ded89c | ||
|
|
7ebcbd799b | ||
|
|
4e492fb6ae | ||
|
|
3544195aeb | ||
|
|
f32c4fdc97 | ||
|
|
bdc8355216 | ||
|
|
01f5f2281e | ||
|
|
24d1ce5e2c | ||
|
|
8e078bb0f4 | ||
|
|
16843fd15f | ||
|
|
ca7357338f | ||
|
|
50a4644a4e | ||
|
|
6b59afee62 | ||
|
|
15442b789b | ||
|
|
a62e610f36 | ||
|
|
bc3983cb8f | ||
|
|
3abf60fd8f | ||
|
|
406e39d2fe | ||
|
|
d238da4906 | ||
|
|
366a9c47e9 | ||
|
|
de5b4e02fe | ||
|
|
9ecf3e94c3 | ||
|
|
164835e190 | ||
|
|
0353113434 | ||
|
|
4481d39247 | ||
|
|
460858d826 | ||
|
|
0f57f77cbf | ||
|
|
8122ad99a0 | ||
|
|
8fbbc33d87 | ||
|
|
5a6af193d2 | ||
|
|
f27c7e0580 | ||
|
|
b74bb0caa2 | ||
|
|
cad365b53e | ||
|
|
64bbd2a9b1 | ||
|
|
3cdfd7de02 | ||
|
|
a54868776d | ||
|
|
e55055534f | ||
|
|
97aa1e1972 | ||
|
|
d0dfa37e50 | ||
|
|
066f665aac | ||
|
|
f5a908584c | ||
|
|
9c3fc30c81 | ||
|
|
adde31f807 | ||
|
|
b213e4c8a6 | ||
|
|
648daa5f9f | ||
|
|
ea8d9c5427 | ||
|
|
d95fe87b06 | ||
|
|
4d66cad51e | ||
|
|
41384109cb | ||
|
|
715ea30809 | ||
|
|
935d30f144 | ||
|
|
a50efff25c | ||
|
|
0ce5a8173a | ||
|
|
bd2918e20e | ||
|
|
493c4fb2e7 | ||
|
|
23156b429b | ||
|
|
1caea71a81 | ||
|
|
e29357793a | ||
|
|
86465cf2ef | ||
|
|
e57c3d99d5 | ||
|
|
2b63c8c7b9 | ||
|
|
16778c720d | ||
|
|
ea2f5254e0 | ||
|
|
bc2d51a8f9 | ||
|
|
94a58a2d80 | ||
|
|
4f12f6bafd | ||
|
|
e0cabfeb29 | ||
|
|
9d4624b29a | ||
|
|
b8ef17a7ba | ||
|
|
d9885c9de3 | ||
|
|
d09b91a4ca | ||
|
|
4356c0a503 | ||
|
|
5045e25f38 | ||
|
|
810adc38b8 | ||
|
|
9791ffeaf6 | ||
|
|
609bf4a82d | ||
|
|
a450ae2510 | ||
|
|
ab683707f8 | ||
|
|
8fb6e3a080 | ||
|
|
3788cea8b1 | ||
|
|
40c6be6654 | ||
|
|
75f928c3bf | ||
|
|
19da3c6ab9 | ||
|
|
b548f9fed2 | ||
|
|
642fd6164f | ||
|
|
594b5be6c7 | ||
|
|
e7286a5f0f | ||
|
|
08ae6a0940 | ||
|
|
b71ed32c70 | ||
|
|
1cf7c85f02 | ||
|
|
71d4904d20 | ||
|
|
ee8989bc20 | ||
|
|
459754c745 | ||
|
|
f35b3d0a55 | ||
|
|
b9ccf3124a | ||
|
|
b43ffced81 | ||
|
|
4f6e7fa14b | ||
|
|
181eb40357 | ||
|
|
152ac45f57 | ||
|
|
c6c4234f87 | ||
|
|
d9b7373f3e | ||
|
|
496136fd83 | ||
|
|
c1edead81e | ||
|
|
1d613f6227 | ||
|
|
cb85a7fc2f | ||
|
|
2696876747 | ||
|
|
8ec03334a6 | ||
|
|
3639f1ae31 | ||
|
|
b2b36e6adb | ||
|
|
b298e8d866 | ||
|
|
72b59a9208 | ||
|
|
29d1264dcc | ||
|
|
39f3e3c296 | ||
|
|
cd378adf89 | ||
|
|
7cf7777b1b | ||
|
|
9ba7a45c3f | ||
|
|
1515ecaa22 | ||
|
|
6de4c21220 | ||
|
|
1d26bea4e9 | ||
|
|
fb776cf92a | ||
|
|
ac1ec4a6c3 | ||
|
|
f5c939518e | ||
|
|
5fc17b73a0 | ||
|
|
b16fc7135f | ||
|
|
fb19176de5 | ||
|
|
f6aa3c7aac | ||
|
|
f3c6029f0f | ||
|
|
dcadd16ed7 | ||
|
|
41b66d5450 | ||
|
|
94530f010e | ||
|
|
ec7aeac08c | ||
|
|
976518e524 | ||
|
|
2c5d1282d7 | ||
|
|
85f69b9dfb | ||
|
|
e9cb529da8 | ||
|
|
3368012af1 | ||
|
|
e7fe551d0c | ||
|
|
de0fe99ac7 | ||
|
|
683f4934ad | ||
|
|
b0b94839f9 | ||
|
|
c92f9978eb | ||
|
|
1398d94d59 | ||
|
|
a2a8f10fd4 | ||
|
|
82cd6a82de | ||
|
|
c124acee9e | ||
|
|
53d5ba413a | ||
|
|
59c9bc34f4 | ||
|
|
9be5565daf | ||
|
|
41bbfc1600 | ||
|
|
fbc32e6736 | ||
|
|
5a6dcc2899 | ||
|
|
f567ab3ec2 | ||
|
|
d160acaf12 | ||
|
|
2dc08c0da7 | ||
|
|
86152dac82 | ||
|
|
2ed80a5074 | ||
|
|
5a00bec733 | ||
|
|
707c5982af | ||
|
|
e1a37ef4fa | ||
|
|
b9078b8862 | ||
|
|
b8d60f7593 | ||
|
|
2dcfca1388 | ||
|
|
d0959a43c4 | ||
|
|
8e49696d02 | ||
|
|
4d8c781369 | ||
|
|
11f3ae7009 | ||
|
|
23c640f65f | ||
|
|
18881fdd97 | ||
|
|
98f348ebd3 | ||
|
|
7075f6c4d7 | ||
|
|
0f20a43f0a | ||
|
|
9db55c93ed | ||
|
|
cd4eda8814 | ||
|
|
2830825613 | ||
|
|
71b1384057 | ||
|
|
b119b7aeb0 | ||
|
|
a4712097f8 | ||
|
|
b55b0bb540 | ||
|
|
c81399a82d | ||
|
|
91ac5e2018 | ||
|
|
5206d0e837 | ||
|
|
484a007aad | ||
|
|
d596a43f6b | ||
|
|
5c47015b6b | ||
|
|
58f4166814 | ||
|
|
78e9f09a8b | ||
|
|
7ae67fd601 | ||
|
|
16a4936f47 | ||
|
|
5200773ca7 | ||
|
|
42b0f185e2 | ||
|
|
cfe2b493bb | ||
|
|
3bfb24c8cb | ||
|
|
f1bdd50116 | ||
|
|
ba4783868d | ||
|
|
28b6f13879 | ||
|
|
7488c4f61e | ||
|
|
af6ead8086 | ||
|
|
17afb1c9ea | ||
|
|
96510405be |
3
.babelrc
3
.babelrc
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"presets": [["@babel/preset-env", {
|
"presets": [["@babel/preset-env", {
|
||||||
"useBuiltIns": "entry",
|
"useBuiltIns": "entry",
|
||||||
"modules": "umd",
|
"modules": "cjs",
|
||||||
|
"loose": true,
|
||||||
"targets": {
|
"targets": {
|
||||||
"ie": "8",
|
"ie": "8",
|
||||||
"browsers": ">2%"
|
"browsers": ">2%"
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
repo_token: Ba2bS7pOlSLZWuESBnff8qxDjIS8Mg1Z0
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ rules:
|
|||||||
- 'error'
|
- 'error'
|
||||||
- 'ignorePackages'
|
- 'ignorePackages'
|
||||||
- {js: 'always'}
|
- {js: 'always'}
|
||||||
|
import/prefer-default-export: 1
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- ava
|
- ava
|
||||||
|
|||||||
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github: lancedikson
|
||||||
|
open_collective: lancedikson
|
||||||
129
.github/copilot-instructions.md
vendored
Normal file
129
.github/copilot-instructions.md
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
# Copilot Instructions for Bowser
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
Bowser is a small, fast, and rich-API browser/platform/engine detector for both browser and Node.js environments. It's designed to parse User-Agent strings and provide detailed information about browsers, operating systems, platforms, and rendering engines.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
### Core Components
|
||||||
|
|
||||||
|
- **`src/bowser.js`**: Main entry point and public API. Provides static methods `getParser()` and `parse()`.
|
||||||
|
- **`src/parser.js`**: Core parsing engine that orchestrates all parsers and returns structured results.
|
||||||
|
- **`src/parser-browsers.js`**: Browser detection logic using regex patterns.
|
||||||
|
- **`src/parser-os.js`**: Operating system detection logic.
|
||||||
|
- **`src/parser-platforms.js`**: Platform type detection (desktop, tablet, mobile).
|
||||||
|
- **`src/parser-engines.js`**: Rendering engine detection (WebKit, Blink, Gecko, etc.).
|
||||||
|
- **`src/constants.js`**: Centralized constants including browser aliases and mappings.
|
||||||
|
- **`src/utils.js`**: Utility functions for string matching and manipulation.
|
||||||
|
|
||||||
|
### Build Output
|
||||||
|
|
||||||
|
- **`es5.js`**: ES5 transpiled version (default export).
|
||||||
|
- **`bundled.js`**: ES5 version with babel-polyfill included.
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Commands
|
||||||
|
|
||||||
|
- **Build**: `npm run build` - Compiles source files using Webpack and Babel.
|
||||||
|
- **Test**: `npm test` - Runs unit and acceptance tests using AVA.
|
||||||
|
- **Lint**: `npm run lint:check` - Checks code style using ESLint.
|
||||||
|
- **Lint Fix**: `npm run lint:fix` - Auto-fixes linting issues.
|
||||||
|
- **Watch Mode**: `npm run watch` - Builds on file changes.
|
||||||
|
- **Test Watch**: `npm run test:watch` - Runs tests on file changes.
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
- Tests are located in `test/acceptance/` and `test/unit/`.
|
||||||
|
- Acceptance tests use real User-Agent strings from `test/acceptance/useragentstrings.yml`.
|
||||||
|
- Always update `useragentstrings.yml` when adding browser support.
|
||||||
|
- Test framework: AVA with Babel integration.
|
||||||
|
|
||||||
|
## Coding Standards
|
||||||
|
|
||||||
|
### Style Guide
|
||||||
|
|
||||||
|
- **ESLint Config**: Based on Airbnb Base style guide.
|
||||||
|
- **Parser**: Uses `babel-eslint`.
|
||||||
|
- **Exceptions**:
|
||||||
|
- Underscore-dangle allowed for private properties.
|
||||||
|
- `no-void` disabled.
|
||||||
|
- ES6 imports must include `.js` extension.
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
- **Browser Aliases**: Use lowercase letters, replace spaces/dashes with underscores, drop "browser" suffix.
|
||||||
|
- Examples: `Opera Coast` → `opera_coast`, `UC Browser` → `uc`, `SeaMonkey` → `seamonkey`.
|
||||||
|
- **Private Properties**: Prefix with underscore (e.g., `_ua`).
|
||||||
|
- **Constants**: Use `UPPER_SNAKE_CASE` for constant maps and aliases.
|
||||||
|
|
||||||
|
### Code Patterns
|
||||||
|
|
||||||
|
- Use ES6 modules with explicit `.js` extensions.
|
||||||
|
- Prefer static methods in Bowser class.
|
||||||
|
- Use class-based structure for Parser.
|
||||||
|
- Regex patterns should be well-documented and tested.
|
||||||
|
- Keep parsers modular and focused on single responsibility.
|
||||||
|
|
||||||
|
## Adding Browser Support
|
||||||
|
|
||||||
|
When adding support for a new browser:
|
||||||
|
|
||||||
|
1. Add regex pattern to `src/parser-browsers.js`.
|
||||||
|
2. Add browser name to `BROWSER_ALIASES_MAP` in `src/constants.js`.
|
||||||
|
3. Add corresponding entry to `BROWSER_MAP`.
|
||||||
|
4. Add test cases to `test/acceptance/useragentstrings.yml`.
|
||||||
|
5. Run tests to verify: `npm test`.
|
||||||
|
6. Check for duplicates before adding aliases.
|
||||||
|
|
||||||
|
## Branching Strategy
|
||||||
|
|
||||||
|
- **`master`**: Development branch.
|
||||||
|
- **`production`**: Production branch.
|
||||||
|
- **New Features**: Branch from `master`, PR back to `master`.
|
||||||
|
- **Hot-fixes/Browser Support**: Branch from `production`, PR back to `production`.
|
||||||
|
|
||||||
|
## Important Files
|
||||||
|
|
||||||
|
- **`index.d.ts`**: TypeScript definitions.
|
||||||
|
- **`.babelrc`**: Babel configuration for ES5 transpilation.
|
||||||
|
- **`webpack.config.js`**: Build configuration.
|
||||||
|
- **`.eslintrc.yml`**: Linting rules.
|
||||||
|
- **`package.json`**: Dependencies and scripts.
|
||||||
|
|
||||||
|
## API Design Principles
|
||||||
|
|
||||||
|
- Keep the API simple and intuitive.
|
||||||
|
- Bowser class should be stateless and provide factory methods.
|
||||||
|
- Parser class handles instance-specific logic.
|
||||||
|
- Results should be structured and predictable.
|
||||||
|
- Support both immediate parsing and lazy parsing.
|
||||||
|
|
||||||
|
## Performance Considerations
|
||||||
|
|
||||||
|
- Parsers use lazy evaluation where possible.
|
||||||
|
- Regex patterns are optimized for common browsers first.
|
||||||
|
- Optional `skipParsing` parameter for delayed parsing.
|
||||||
|
- Minimal bundle size is a priority (~4.8kB gzipped).
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- Use JSDoc comments for all public APIs.
|
||||||
|
- Document parameters, return types, and provide examples.
|
||||||
|
- Update README.md for API changes.
|
||||||
|
- Generate docs with: `npm run generate-docs`.
|
||||||
|
|
||||||
|
## Common Pitfalls
|
||||||
|
|
||||||
|
- Always check `BROWSER_ALIASES_MAP` for existing aliases before adding new ones.
|
||||||
|
- User-Agent strings can be complex; test edge cases thoroughly.
|
||||||
|
- Remember to update both the alias map and the reverse map in constants.
|
||||||
|
- Browser versions should be treated as strings, not numbers.
|
||||||
|
- Keep regex patterns readable with comments explaining their purpose.
|
||||||
19
.github/release-drafter.yml
vendored
Normal file
19
.github/release-drafter.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name-template: 'v$RESOLVED_VERSION 🌈'
|
||||||
|
tag-template: 'v$RESOLVED_VERSION'
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- major
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- minor
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- patch
|
||||||
|
default: patch
|
||||||
|
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||||
|
change-title-escapes: '\<*_&'
|
||||||
|
template: |
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
$CHANGES
|
||||||
20
.github/workflows/draft-or-update-next-release.yml
vendored
Normal file
20
.github/workflows/draft-or-update-next-release.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: 📝 Draft or update next release
|
||||||
|
concurrency: draft_or_update_next_release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare-deployment:
|
||||||
|
name: 📝 Draft or update next release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
38
.github/workflows/merge-to-master.yml
vendored
Normal file
38
.github/workflows/merge-to-master.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: "Merge to master"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [12.16.3]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get branch name (merge)
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
shell: bash
|
||||||
|
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Get branch name (pull request)
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
shell: bash
|
||||||
|
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: npm i -g nyc@15
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- run: nyc npm test && nyc report --reporter=text-lcov | ./node_modules/coveralls/bin/coveralls.js
|
||||||
|
env:
|
||||||
|
COVERALLS_SERVICE_NAME: GithubActions
|
||||||
|
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
||||||
|
COVERALLS_GIT_BRANCH: ${{ env.BRANCH_NAME }}
|
||||||
63
.github/workflows/publish.yml
vendored
Normal file
63
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
# This job runs when a new release is published
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
# Manual trigger with version input
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Version to release (e.g., 2.12.1)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 12.16.3
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
|
||||||
|
# Store the release version (from release tag or manual input)
|
||||||
|
- name: Set release version
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||||
|
echo "Manual release triggered for version: ${{ github.event.inputs.version }}"
|
||||||
|
else
|
||||||
|
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
echo "Release triggered from tag: ${GITHUB_REF#refs/*/}"
|
||||||
|
fi
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm version $RELEASE_VERSION --no-git-tag-version
|
||||||
|
- run: npm run build
|
||||||
|
- name: Publish to npm with retry
|
||||||
|
run: |
|
||||||
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
while [ $attempt -le $max_attempts ]; do
|
||||||
|
echo "Attempt $attempt of $max_attempts..."
|
||||||
|
if npm publish --access public; then
|
||||||
|
echo "Successfully published!"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
if [ $attempt -eq $max_attempts ]; then
|
||||||
|
echo "Failed to publish after $max_attempts attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Publish failed, waiting before retry..."
|
||||||
|
sleep_time=$((attempt * 30))
|
||||||
|
echo "Waiting ${sleep_time} seconds before retry..."
|
||||||
|
sleep $sleep_time
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.BOWSER_NPM_PUBLISH_TOKEN }}
|
||||||
44
.github/workflows/pull-request.yml
vendored
Normal file
44
.github/workflows/pull-request.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: "Pull Request"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened, synchronize]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node: [12.16.3]
|
||||||
|
name: Node ${{ matrix.node }}
|
||||||
|
steps:
|
||||||
|
- name: "Checkout latest code"
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Set up node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
|
lint:
|
||||||
|
name: "ESLint"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout latest code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Set up node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "16"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Run ESLint
|
||||||
|
run: npm run lint:check
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,5 +3,5 @@ node_modules/
|
|||||||
.nyc_output
|
.nyc_output
|
||||||
coverage
|
coverage
|
||||||
dist
|
dist
|
||||||
bundled.js
|
bundled.js*
|
||||||
es5.js
|
es5.js*
|
||||||
|
|||||||
@ -3,3 +3,8 @@ test
|
|||||||
coverage
|
coverage
|
||||||
**/.*
|
**/.*
|
||||||
node_modules
|
node_modules
|
||||||
|
.github
|
||||||
|
docs
|
||||||
|
*.gz
|
||||||
|
jsdoc.json
|
||||||
|
webpack.config.js
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
after_success: npm run coverage
|
|
||||||
node_js:
|
|
||||||
- "8.4.0"
|
|
||||||
script:
|
|
||||||
- npm run lint
|
|
||||||
- npm run build
|
|
||||||
- npm test
|
|
||||||
66
CHANGELOG.md
66
CHANGELOG.md
@ -1,5 +1,71 @@
|
|||||||
# Bowser Changelog
|
# Bowser Changelog
|
||||||
|
|
||||||
|
### 2.11.0 (Sep 12, 2020)
|
||||||
|
- [ADD] Added support for aliases in `Parser#is` method (#437)
|
||||||
|
- [ADD] Added more typings (#438, #427)
|
||||||
|
- [ADD] Added support for MIUI Browser (#436)
|
||||||
|
|
||||||
|
### 2.10.0 (Jul 9, 2020)
|
||||||
|
- [FIX] Fix for Firefox detection on iOS 13 [#415]
|
||||||
|
- [FIX] Fixes for typings.d.ts [#409]
|
||||||
|
- [FIX] Updated development dependencies
|
||||||
|
|
||||||
|
### 2.9.0 (Jan 28, 2020)
|
||||||
|
- [ADD] Export more methods and constants via .d.ts [#388], [#390]
|
||||||
|
|
||||||
|
### 2.8.1 (Dec 26, 2019)
|
||||||
|
- [FIX] Reverted [#382] as it broke build
|
||||||
|
|
||||||
|
### 2.8.0 (Dec 26, 2019)
|
||||||
|
- [ADD] Add polyfills for Array.find & Object.assign [#383]
|
||||||
|
- [ADD] Export constants with types.d.ts [#382]
|
||||||
|
- [FIX] Add support for WeChat on Windows [#381]
|
||||||
|
- [FIX] Fix detection of Firefox on iPad [#379]
|
||||||
|
- [FIX] Add detection of Electron [#375]
|
||||||
|
- [FIX] Updated dev-dependencies
|
||||||
|
|
||||||
|
### 2.7.0 (Oct 2, 2019)
|
||||||
|
- [FIX] Add support for QQ Browser [#362]
|
||||||
|
- [FIX] Add support for GSA [#364]
|
||||||
|
- [FIX] Updated dependencies
|
||||||
|
|
||||||
|
### 2.6.0 (Sep 6, 2019)
|
||||||
|
- [ADD] Define "module" export in package.json [#354]
|
||||||
|
- [FIX] Fix Tablet PC detection [#334]
|
||||||
|
|
||||||
|
### 2.5.4 (Sep 2, 2019)
|
||||||
|
- [FIX] Exclude docs from the npm package [#349]
|
||||||
|
|
||||||
|
### 2.5.3 (Aug 4, 2019)
|
||||||
|
- [FIX] Add MacOS names support [#338]
|
||||||
|
- [FIX] Point typings.d.ts from package.json [#341]
|
||||||
|
- [FIX] Upgrade dependencies
|
||||||
|
|
||||||
|
### 2.5.2 (July 17, 2019)
|
||||||
|
- [FIX] Fixes the bug undefined method because of failed build (#335)
|
||||||
|
|
||||||
|
### 2.5.1 (July 17, 2019)
|
||||||
|
- [FIX] Fixes the bug with a custom Error class (#335)
|
||||||
|
- [FIX] Fixes the settings for Babel to reduce the bundle size (#259)
|
||||||
|
|
||||||
|
### 2.5.0 (July 16, 2019)
|
||||||
|
- [ADD] Add constant output so that users can quickly get all types (#325)
|
||||||
|
- [FIX] Add support for Roku OS (#332)
|
||||||
|
- [FIX] Update devDependencies
|
||||||
|
- [FIX] Fix docs, README and added funding information
|
||||||
|
|
||||||
|
### 2.4.0 (May 3, 2019)
|
||||||
|
- [FIX] Update regexp for generic browsers (#310)
|
||||||
|
- [FIX] Fix issues with module.exports (#318)
|
||||||
|
- [FIX] Update devDependencies (#316, #321, #322)
|
||||||
|
- [FIX] Fix docs (#320)
|
||||||
|
|
||||||
|
### 2.3.0 (April 14, 2019)
|
||||||
|
- [ADD] Add support for Blink-based MS Edge (#311)
|
||||||
|
- [ADD] Add more types for TS (#289)
|
||||||
|
- [FIX] Update dev-dependencies
|
||||||
|
- [FIX] Update docs
|
||||||
|
|
||||||
### 2.2.1 (April 12, 2019)
|
### 2.2.1 (April 12, 2019)
|
||||||
- [ADD] Add an alias for Samsung Internet
|
- [ADD] Add an alias for Samsung Internet
|
||||||
- [FIX] Fix browser name detection for browsers without an alias (#313)
|
- [FIX] Fix browser name detection for browsers without an alias (#313)
|
||||||
|
|||||||
51
README.md
51
README.md
@ -1,23 +1,26 @@
|
|||||||
## Bowser
|
## Bowser
|
||||||
A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.
|
A small, fast and rich-API browser/platform/engine detector for both browser and node.
|
||||||
|
- **Small.** Use plain ES5-version which is ~4.8kB gzipped.
|
||||||
|
- **Optimized.** Use only those parsers you need — it doesn't do useless work.
|
||||||
|
- **Multi-platform.** It's browser- and node-ready, so you can use it in any environment.
|
||||||
|
|
||||||
[](https://travis-ci.org/lancedikson/bowser/) [](https://greenkeeper.io/)[](https://coveralls.io/github/lancedikson/bowser?branch=master)
|
Don't hesitate to support the project on Github or [OpenCollective](https://opencollective.com/bowser) if you like it ❤️ Also, contributors are always welcome!
|
||||||
|
|
||||||
|
[](https://opencollective.com/bowser) [](https://travis-ci.org/bowser-js/bowser/) [](https://greenkeeper.io/) [](https://coveralls.io/github/bowser-js/bowser?branch=master) 
|
||||||
|
|
||||||
# Contents
|
# Contents
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
- [Use cases](#use-cases)
|
- [Use cases](#use-cases)
|
||||||
- [Advanced usage](#advanced-usage)
|
|
||||||
- [How can I help?](#contributing)
|
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
|
|
||||||
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.
|
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. Check it out on this page: https://bowser-js.github.io/bowser-online/.
|
||||||
|
|
||||||
### ⚠️ Version 2.0 breaking changes ⚠️
|
### ⚠️ Version 2.0 breaking changes ⚠️
|
||||||
|
|
||||||
Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://lancedikson.github.io/bowser/docs).
|
Version 2.0 has drastically changed the API. All available methods are on the [docs page](https://bowser-js.github.io/bowser/docs/).
|
||||||
|
|
||||||
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
|
_For legacy code, check out the [1.x](https://github.com/bowser-js/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
|
||||||
|
|
||||||
# Use cases
|
# Use cases
|
||||||
|
|
||||||
@ -115,13 +118,13 @@ const isValidBrowser = browser.satisfies({
|
|||||||
// or in general
|
// or in general
|
||||||
chrome: "~20.1.1432",
|
chrome: "~20.1.1432",
|
||||||
firefox: ">31",
|
firefox: ">31",
|
||||||
opera: ">=22"
|
opera: ">=22",
|
||||||
|
|
||||||
// also supports equality operator
|
// also supports equality operator
|
||||||
chrome: "=20.1.1432", // will match particular build only
|
chrome: "=20.1.1432", // will match particular build only
|
||||||
|
|
||||||
// and loose-equality operator
|
// and loose-equality operator
|
||||||
chrome: "~20" // will match any 20.* sub-version
|
chrome: "~20", // will match any 20.* sub-version
|
||||||
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
|
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@ -140,5 +143,35 @@ list of aliases can be found in [the file](src/constants.js).
|
|||||||
## Similar Projects
|
## Similar Projects
|
||||||
* [Kong](https://github.com/BigBadBleuCheese/Kong) - A C# port of Bowser.
|
* [Kong](https://github.com/BigBadBleuCheese/Kong) - A C# port of Bowser.
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
### Code Contributors
|
||||||
|
|
||||||
|
This project exists thanks to all the people who contribute. [[Contribute](.github/CONTRIBUTING.md)].
|
||||||
|
<a href="https://github.com/bowser-js/bowser/graphs/contributors"><img src="https://opencollective.com/bowser/contributors.svg?width=890&button=false" /></a>
|
||||||
|
|
||||||
|
### Financial Contributors
|
||||||
|
|
||||||
|
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/bowser/contribute)]
|
||||||
|
|
||||||
|
#### Individuals
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/bowser"><img src="https://opencollective.com/bowser/individuals.svg?width=890"></a>
|
||||||
|
|
||||||
|
#### Organizations
|
||||||
|
|
||||||
|
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/bowser/contribute)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/bowser/organization/0/website"><img src="https://opencollective.com/bowser/organization/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/1/website"><img src="https://opencollective.com/bowser/organization/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/2/website"><img src="https://opencollective.com/bowser/organization/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/3/website"><img src="https://opencollective.com/bowser/organization/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/4/website"><img src="https://opencollective.com/bowser/organization/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/5/website"><img src="https://opencollective.com/bowser/organization/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/6/website"><img src="https://opencollective.com/bowser/organization/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/7/website"><img src="https://opencollective.com/bowser/organization/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/8/website"><img src="https://opencollective.com/bowser/organization/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/9/website"><img src="https://opencollective.com/bowser/organization/9/avatar.svg"></a>
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||||
|
|||||||
112
docs/Bowser.html
112
docs/Bowser.html
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -47,105 +48,17 @@
|
|||||||
Bowser
|
Bowser
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="class-description"><p>Bowser class.
|
<div class="class-description"><p>Bowser is a static object, that provides an API to the Parsers</p></div>
|
||||||
Keep it simple as much as it can be.
|
|
||||||
It's supposed to work with collections of <a href="Parser.html">Parser</a> instances
|
|
||||||
rather then solve one-instance problems.
|
|
||||||
All the one-instance stuff is located in Parser class.</p></div>
|
|
||||||
|
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<div class="container-overview">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Constructor</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="Bowser"><span class="type-signature"></span>new Bowser<span class="signature">()</span><span class="type-signature"></span></h4>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dl class="details">
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
|
||||||
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line16">line 16</a>
|
|
||||||
</li></ul></dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +90,7 @@ All the one-instance stuff is located in Parser class.</p></div>
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line29">line 29</a>
|
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line40">line 40</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +130,7 @@ All the one-instance stuff is located in Parser class.</p></div>
|
|||||||
|
|
||||||
|
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<p>Creates a module:parser:Parser instance</p>
|
<p>Creates a <a href="Parser.html">Parser</a> instance</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +245,8 @@ const result = parser.getResult();</code></pre>
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td class="description last"><p>same as skipParsing for <a href="Parser.html">Parser</a></p></td>
|
<td class="description last"><p>Will make the Parser postpone parsing until you ask it
|
||||||
|
explicitly. Same as <code>skipParsing</code> for <a href="Parser.html">Parser</a>.</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
@ -350,6 +264,8 @@ const result = parser.getResult();</code></pre>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Throws:</h5>
|
<h5>Throws:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -406,6 +322,7 @@ const result = parser.getResult();</code></pre>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(UA)</span><span class="type-signature"> → {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
|
<h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(UA)</span><span class="type-signature"> → {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -418,7 +335,7 @@ const result = parser.getResult();</code></pre>
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line45">line 45</a>
|
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line56">line 56</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -532,6 +449,8 @@ const result = parser.getResult();</code></pre>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -558,6 +477,7 @@ const result = parser.getResult();</code></pre>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
@ -572,12 +492,14 @@ const result = parser.getResult();</code></pre>
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
234
docs/BowserUAIsNotAStringError.html
Normal file
234
docs/BowserUAIsNotAStringError.html
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>BowserUAIsNotAStringError - Documentation</title>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="scripts/prettify/prettify.js"></script>
|
||||||
|
<script src="scripts/prettify/lang-css.js"></script>
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<nav >
|
||||||
|
|
||||||
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="BowserUAIsNotAStringError.html">BowserUAIsNotAStringError</a></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">BowserUAIsNotAStringError</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
BowserUAIsNotAStringError
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<div class="container-overview">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="BowserUAIsNotAStringError"><span class="type-signature"></span>new BowserUAIsNotAStringError<span class="signature">()</span><span class="type-signature"></span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="bowser.js.html">bowser.js</a>, <a href="bowser.js.html#line20">line 20</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5 class="subsection-title">Properties:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<table class="props">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>name</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Jul 16 2019 22:20:27 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
366
docs/Parser.html
366
docs/Parser.html
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -74,7 +75,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line10">line 10</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line23">line 23</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -248,6 +249,9 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -264,6 +268,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3 class="subsection-title">Methods</h3>
|
<h3 class="subsection-title">Methods</h3>
|
||||||
|
|
||||||
|
|
||||||
@ -345,6 +351,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -373,6 +381,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getBrowserName"><span class="type-signature"></span>getBrowserName<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getBrowserName"><span class="type-signature"></span>getBrowserName<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -447,6 +456,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -479,6 +490,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getBrowserVersion"><span class="type-signature"></span>getBrowserVersion<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getBrowserVersion"><span class="type-signature"></span>getBrowserVersion<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -553,6 +565,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -585,6 +599,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getEngine"><span class="type-signature"></span>getEngine<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
<h4 class="name" id="getEngine"><span class="type-signature"></span>getEngine<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -659,6 +674,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -687,6 +704,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getEngineName"><span class="type-signature"></span>getEngineName<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getEngineName"><span class="type-signature"></span>getEngineName<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -761,6 +779,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -793,6 +813,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getOS"><span class="type-signature"></span>getOS<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
<h4 class="name" id="getOS"><span class="type-signature"></span>getOS<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -879,6 +900,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -904,6 +927,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getOSName"><span class="type-signature"></span>getOSName<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getOSName"><span class="type-signature"></span>getOSName<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1042,6 +1066,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -1071,6 +1097,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getOSVersion"><span class="type-signature"></span>getOSVersion<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getOSVersion"><span class="type-signature"></span>getOSVersion<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1145,6 +1172,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1177,6 +1206,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getPlatform"><span class="type-signature"></span>getPlatform<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
<h4 class="name" id="getPlatform"><span class="type-signature"></span>getPlatform<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1251,6 +1281,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1279,6 +1311,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getPlatformType"><span class="type-signature"></span>getPlatformType<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
|
<h4 class="name" id="getPlatformType"><span class="type-signature"></span>getPlatformType<span class="signature">(toLowerCase<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {*}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1425,6 +1458,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -1450,6 +1485,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getResult"><span class="type-signature"></span>getResult<span class="signature">()</span><span class="type-signature"> → {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
|
<h4 class="name" id="getResult"><span class="type-signature"></span>getResult<span class="signature">()</span><span class="type-signature"> → {<a href="global.html#ParsedResult">ParsedResult</a>}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1462,7 +1498,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line330">line 330</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line331">line 331</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -1524,6 +1560,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1552,6 +1590,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getUA"><span class="type-signature"></span>getUA<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
<h4 class="name" id="getUA"><span class="type-signature"></span>getUA<span class="signature">()</span><span class="type-signature"> → {String}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1626,6 +1665,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1658,7 +1699,8 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="is"><span class="type-signature"></span>is<span class="signature">(anything)</span><span class="type-signature"> → {Boolean}</span></h4>
|
|
||||||
|
<h4 class="name" id="is"><span class="type-signature"></span>is<span class="signature">(anything, includingAlias<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Boolean}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1670,7 +1712,7 @@ like <a href="Parser.html#parseBrowser">Parser#parseBrowser</a> or <a href="Pars
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line470">line 470</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line481">line 481</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -1737,9 +1779,13 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Attributes</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>Default</th>
|
||||||
|
|
||||||
|
|
||||||
<th class="last">Description</th>
|
<th class="last">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -1762,13 +1808,59 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="attributes">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="default">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td class="description last"></td>
|
<td class="description last"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>includingAlias</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="attributes">
|
||||||
|
|
||||||
|
<optional><br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="default">
|
||||||
|
|
||||||
|
<code>false</code>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"><p>The flag showing whether alias will be included into comparison</p></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -1785,6 +1877,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -1810,7 +1904,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">()</span><span class="type-signature"></span></h4>
|
|
||||||
|
<h4 class="name" id="isBrowser"><span class="type-signature"></span>isBrowser<span class="signature">(browserName, includingAlias<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {boolean}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1822,7 +1917,206 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line317">line 317</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line415">line 415</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Check if the browser name equals the passed string</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Attributes</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th>Default</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>browserName</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="attributes">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="default">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"><p>The string to compare with the browser name</p></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>includingAlias</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="attributes">
|
||||||
|
|
||||||
|
<optional><br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="default">
|
||||||
|
|
||||||
|
<code>false</code>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"><p>The flag showing whether alias will be included into comparison</p></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type">boolean</span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">()</span><span class="type-signature"> → {<a href="Parser.html">Parser</a>}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line318">line 318</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -1884,6 +2178,27 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type"><a href="Parser.html">Parser</a></span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1968,6 +2283,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1996,6 +2313,7 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="parseEngine"><span class="type-signature"></span>parseEngine<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
<h4 class="name" id="parseEngine"><span class="type-signature"></span>parseEngine<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2070,6 +2388,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2098,6 +2418,7 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="parseOS"><span class="type-signature"></span>parseOS<span class="signature">()</span><span class="type-signature"> → {*|Object}</span></h4>
|
<h4 class="name" id="parseOS"><span class="type-signature"></span>parseOS<span class="signature">()</span><span class="type-signature"> → {*|Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2172,6 +2493,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2203,6 +2526,7 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="parsePlatform"><span class="type-signature"></span>parsePlatform<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
<h4 class="name" id="parsePlatform"><span class="type-signature"></span>parsePlatform<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2277,6 +2601,8 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2305,6 +2631,7 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="satisfies"><span class="type-signature"></span>satisfies<span class="signature">(checkTree)</span><span class="type-signature"> → {Boolean|undefined}</span></h4>
|
<h4 class="name" id="satisfies"><span class="type-signature"></span>satisfies<span class="signature">(checkTree)</span><span class="type-signature"> → {Boolean|undefined}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2317,7 +2644,7 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line352">line 352</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line353">line 353</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -2370,12 +2697,12 @@ the OS called "anything" or the platform called "anything"</
|
|||||||
|
|
||||||
<h5>Example</h5>
|
<h5>Example</h5>
|
||||||
|
|
||||||
<pre class="prettyprint"><code>const browser = new Bowser(UA);
|
<pre class="prettyprint"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
if (browser.check({chrome: '>118.01.1322' }))
|
if (browser.satisfies({chrome: '>118.01.1322' }))
|
||||||
// or with os
|
// or with os
|
||||||
if (browser.check({windows: { chrome: '>118.01.1322' } }))
|
if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
||||||
// or with platforms
|
// or with platforms
|
||||||
if (browser.check({desktop: { chrome: '>118.01.1322' } }))</code></pre>
|
if (browser.satisfies({desktop: { chrome: '>118.01.1322' } }))</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2443,6 +2770,8 @@ and should have browsers specs on the bottom-laying layer</p></td>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -2476,6 +2805,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="some"><span class="type-signature"></span>some<span class="signature">(anythings)</span><span class="type-signature"> → {Boolean}</span></h4>
|
<h4 class="name" id="some"><span class="type-signature"></span>some<span class="signature">(anythings)</span><span class="type-signature"> → {Boolean}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2488,7 +2818,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line479">line 479</a>
|
<a href="parser.js.html">parser.js</a>, <a href="parser.js.html#line491">line 491</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -2602,6 +2932,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -2627,6 +2959,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(regex)</span><span class="type-signature"> → {Boolean}</span></h4>
|
<h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(regex)</span><span class="type-signature"> → {Boolean}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -2753,6 +3086,8 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -2779,6 +3114,7 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
@ -2793,12 +3129,14 @@ Returns <code>undefined</code> when the browser is no described in the checkTree
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -45,9 +46,15 @@
|
|||||||
* Bowser - a browser detector
|
* Bowser - a browser detector
|
||||||
* https://github.com/lancedikson/bowser
|
* https://github.com/lancedikson/bowser
|
||||||
* MIT License | (c) Dustin Diaz 2012-2015
|
* MIT License | (c) Dustin Diaz 2012-2015
|
||||||
* MIT License | (c) Denis Demchenko 2015-2017
|
* MIT License | (c) Denis Demchenko 2015-2019
|
||||||
*/
|
*/
|
||||||
import Parser from './parser.js';
|
import Parser from './parser.js';
|
||||||
|
import {
|
||||||
|
BROWSER_MAP,
|
||||||
|
ENGINE_MAP,
|
||||||
|
OS_MAP,
|
||||||
|
PLATFORMS_MAP,
|
||||||
|
} from './constants.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bowser class.
|
* Bowser class.
|
||||||
@ -55,13 +62,18 @@ import Parser from './parser.js';
|
|||||||
* It's supposed to work with collections of {@link Parser} instances
|
* It's supposed to work with collections of {@link Parser} instances
|
||||||
* rather then solve one-instance problems.
|
* rather then solve one-instance problems.
|
||||||
* All the one-instance stuff is located in Parser class.
|
* All the one-instance stuff is located in Parser class.
|
||||||
|
*
|
||||||
|
* @class
|
||||||
|
* @classdesc Bowser is a static object, that provides an API to the Parsers
|
||||||
|
* @hideconstructor
|
||||||
*/
|
*/
|
||||||
class Bowser {
|
class Bowser {
|
||||||
/**
|
/**
|
||||||
* Creates a {@link module:parser:Parser} instance
|
* Creates a {@link Parser} instance
|
||||||
*
|
*
|
||||||
* @param {String} UA UserAgent string
|
* @param {String} UA UserAgent string
|
||||||
* @param {Boolean} [skipParsing=false] same as skipParsing for {@link Parser}
|
* @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
|
||||||
|
* explicitly. Same as `skipParsing` for {@link Parser}.
|
||||||
* @returns {Parser}
|
* @returns {Parser}
|
||||||
* @throws {Error} when UA is not a String
|
* @throws {Error} when UA is not a String
|
||||||
*
|
*
|
||||||
@ -88,6 +100,22 @@ class Bowser {
|
|||||||
static parse(UA) {
|
static parse(UA) {
|
||||||
return (new Parser(UA)).getResult();
|
return (new Parser(UA)).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get BROWSER_MAP() {
|
||||||
|
return BROWSER_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get ENGINE_MAP() {
|
||||||
|
return ENGINE_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get OS_MAP() {
|
||||||
|
return OS_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get PLATFORMS_MAP() {
|
||||||
|
return PLATFORMS_MAP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Bowser;
|
export default Bowser;
|
||||||
@ -105,12 +133,14 @@ export default Bowser;
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
732
docs/global.html
732
docs/global.html
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -114,6 +115,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3 class="subsection-title">Methods</h3>
|
<h3 class="subsection-title">Methods</h3>
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +124,360 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="assign"><span class="type-signature"></span>assign<span class="signature">(obj)</span><span class="type-signature"> → {Object}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line265">line 265</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Object::assign polyfill</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>obj</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">Object</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>...objs</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">Object</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type">Object</span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="find"><span class="type-signature"></span>find<span class="signature">(arr, predicate)</span><span class="type-signature"> → {Array}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line243">line 243</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Array::find polyfill</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>arr</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">Array</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>predicate</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">function</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type">Array</span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getAndroidVersionName"><span class="type-signature"></span>getAndroidVersionName<span class="signature">(version)</span><span class="type-signature"> → {string}</span></h4>
|
<h4 class="name" id="getAndroidVersionName"><span class="type-signature"></span>getAndroidVersionName<span class="signature">(version)</span><span class="type-signature"> → {string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +490,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line80">line 80</a>
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line120">line 120</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -188,7 +545,7 @@
|
|||||||
6.x - Marshmallow
|
6.x - Marshmallow
|
||||||
7.x - Nougat
|
7.x - Nougat
|
||||||
8.x - Oreo
|
8.x - Oreo
|
||||||
9.x - ?</p>
|
9.x - Pie</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -267,6 +624,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -296,6 +655,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getBrowserAlias"><span class="type-signature"></span>getBrowserAlias<span class="signature">(browserName)</span><span class="type-signature"> → {string}</span></h4>
|
<h4 class="name" id="getBrowserAlias"><span class="type-signature"></span>getBrowserAlias<span class="signature">(browserName)</span><span class="type-signature"> → {string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -308,7 +668,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line202">line 202</a>
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line293">line 293</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -427,6 +787,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -452,6 +814,166 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="getBrowserTypeByAlias"><span class="type-signature"></span>getBrowserTypeByAlias<span class="signature">(browserAlias)</span><span class="type-signature"> → {string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line306">line 306</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Get short version/alias for a browser name</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Example</h5>
|
||||||
|
|
||||||
|
<pre class="prettyprint"><code>getBrowserAlias('edge') // Microsoft Edge</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>browserAlias</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">string</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type">string</span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getFirstMatch"><span class="type-signature"></span>getFirstMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> → {Array|Object|*|boolean|string}</span></h4>
|
<h4 class="name" id="getFirstMatch"><span class="type-signature"></span>getFirstMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> → {Array|Object|*|boolean|string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -601,6 +1123,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -638,6 +1162,186 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="name" id="getMacOSVersionName"><span class="type-signature"></span>getMacOSVersionName<span class="signature">(version)</span><span class="type-signature"> → {string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line76">line 76</a>
|
||||||
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Get macOS version name
|
||||||
|
10.5 - Leopard
|
||||||
|
10.6 - Snow Leopard
|
||||||
|
10.7 - Lion
|
||||||
|
10.8 - Mountain Lion
|
||||||
|
10.9 - Mavericks
|
||||||
|
10.10 - Yosemite
|
||||||
|
10.11 - El Capitan
|
||||||
|
10.12 - Sierra
|
||||||
|
10.13 - High Sierra
|
||||||
|
10.14 - Mojave
|
||||||
|
10.15 - Catalina
|
||||||
|
11 - Big Sur
|
||||||
|
12 - Monterey
|
||||||
|
13 - Ventura
|
||||||
|
14 - Sonoma
|
||||||
|
15 - Sequoia</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Example</h5>
|
||||||
|
|
||||||
|
<pre class="prettyprint"><code>getMacOSVersionName("10.14") // 'Mojave'</code></pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>version</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">string</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="param-desc">
|
||||||
|
<p>versionName</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="param-type">
|
||||||
|
<dt>
|
||||||
|
Type
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<span class="param-type">string</span>
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getSecondMatch"><span class="type-signature"></span>getSecondMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> → {Array|Object|*|boolean|string}</span></h4>
|
<h4 class="name" id="getSecondMatch"><span class="type-signature"></span>getSecondMatch<span class="signature">(regexp, ua)</span><span class="type-signature"> → {Array|Object|*|boolean|string}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -782,6 +1486,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -819,6 +1525,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="getVersionPrecision"><span class="type-signature"></span>getVersionPrecision<span class="signature">(version)</span><span class="type-signature"> → {number}</span></h4>
|
<h4 class="name" id="getVersionPrecision"><span class="type-signature"></span>getVersionPrecision<span class="signature">(version)</span><span class="type-signature"> → {number}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -831,7 +1538,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line109">line 109</a>
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line150">line 150</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -950,6 +1657,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -975,6 +1684,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(arr, iterator)</span><span class="type-signature"> → {Array}</span></h4>
|
<h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(arr, iterator)</span><span class="type-signature"> → {Array}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -987,7 +1697,7 @@
|
|||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
<dt class="tag-source">Source:</dt>
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
<dd class="tag-source"><ul class="dummy"><li>
|
||||||
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line181">line 181</a>
|
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line224">line 224</a>
|
||||||
</li></ul></dd>
|
</li></ul></dd>
|
||||||
|
|
||||||
|
|
||||||
@ -1124,6 +1834,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -1149,6 +1861,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="matchAndReturnConst"><span class="type-signature"></span>matchAndReturnConst<span class="signature">(regexp, ua, _const)</span><span class="type-signature"> → {*}</span></h4>
|
<h4 class="name" id="matchAndReturnConst"><span class="type-signature"></span>matchAndReturnConst<span class="signature">(regexp, ua, _const)</span><span class="type-signature"> → {*}</span></h4>
|
||||||
|
|
||||||
|
|
||||||
@ -1321,6 +2034,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Returns:</h5>
|
<h5>Returns:</h5>
|
||||||
|
|
||||||
|
|
||||||
@ -1345,6 +2060,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3 class="subsection-title">Type Definitions</h3>
|
<h3 class="subsection-title">Type Definitions</h3>
|
||||||
|
|
||||||
|
|
||||||
@ -1995,12 +2711,14 @@ like <code>"iPhone"</code> or <code>"Kindle Fire HD 7"</code
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -39,6 +40,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section class="package">
|
||||||
|
<h3> </h3>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -50,32 +57,48 @@
|
|||||||
|
|
||||||
|
|
||||||
<section class="readme">
|
<section class="readme">
|
||||||
<article><h2>Bowser</h2><p>A browser detector. Because sometimes, there is no other way, and not even good modern browsers always provide good feature detection mechanisms.</p>
|
<article><h2>Bowser</h2>
|
||||||
<p><a href="https://travis-ci.org/lancedikson/bowser/"><img src="https://travis-ci.org/lancedikson/bowser.svg?branch=master" alt="Build Status"></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/lancedikson/bowser.svg" alt="Greenkeeper badge"></a><a href="https://coveralls.io/github/lancedikson/bowser?branch=master"><img src="https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master" alt="Coverage Status"></a></p>
|
<p>A small, fast and rich-API browser/platform/engine detector for both browser and node.</p>
|
||||||
<h1>Contents</h1><ul>
|
<ul>
|
||||||
|
<li><strong>Small.</strong> Use plain ES5-version which is ~4.8kB gzipped.</li>
|
||||||
|
<li><strong>Optimized.</strong> Use only those parsers you need — it doesn't do useless work.</li>
|
||||||
|
<li><strong>Multi-platform.</strong> It's browser- and node-ready, so you can use it in any environment.</li>
|
||||||
|
</ul>
|
||||||
|
<p>Don't hesitate to support the project on Github or <a href="https://opencollective.com/bowser">OpenCollective</a> if you like it ❤️ Also, contributors are always welcome!</p>
|
||||||
|
<p><a href="https://opencollective.com/bowser"><img src="https://opencollective.com/bowser/all/badge.svg?label=financial+contributors" alt="Financial Contributors on Open Collective"></a> <a href="https://travis-ci.org/lancedikson/bowser/"><img src="https://travis-ci.org/lancedikson/bowser.svg?branch=master" alt="Build Status"></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/lancedikson/bowser.svg" alt="Greenkeeper badge"></a> <a href="https://coveralls.io/github/lancedikson/bowser?branch=master"><img src="https://coveralls.io/repos/github/lancedikson/bowser/badge.svg?branch=master" alt="Coverage Status"></a> <img src="https://img.shields.io/npm/dm/bowser" alt="Downloads"></p>
|
||||||
|
<h1>Contents</h1>
|
||||||
|
<ul>
|
||||||
<li><a href="#overview">Overview</a></li>
|
<li><a href="#overview">Overview</a></li>
|
||||||
<li><a href="#use-cases">Use cases</a></li>
|
<li><a href="#use-cases">Use cases</a></li>
|
||||||
<li><a href="#advanced-usage">Advanced usage</a></li>
|
<li><a href="#advanced-usage">Advanced usage</a></li>
|
||||||
<li><a href="#contributing">How can I help?</a></li>
|
<li><a href="#contributing">How can I help?</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1>Overview</h1><p>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.</p>
|
<h1>Overview</h1>
|
||||||
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3><p>Version 2.0 has drastically changed the API. All available methods are on the <a href="https://lancedikson.github.io/bowser/docs">docs page</a>.</p>
|
<p>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. Check it out on this page: https://bowser-js.github.io/bowser-online/.</p>
|
||||||
|
<h3>⚠️ Version 2.0 breaking changes ⚠️</h3>
|
||||||
|
<p>Version 2.0 has drastically changed the API. All available methods are on the <a href="https://lancedikson.github.io/bowser/docs">docs page</a>.</p>
|
||||||
<p><em>For legacy code, check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch and install it through <code>npm install bowser@1.9.4</code>.</em></p>
|
<p><em>For legacy code, check out the <a href="https://github.com/lancedikson/bowser/tree/v1.x">1.x</a> branch and install it through <code>npm install bowser@1.9.4</code>.</em></p>
|
||||||
<h1>Use cases</h1><p>First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.</p>
|
<h1>Use cases</h1>
|
||||||
|
<p>First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.</p>
|
||||||
<pre class="prettyprint source lang-javascript"><code>const Bowser = require("bowser"); // CommonJS
|
<pre class="prettyprint source lang-javascript"><code>const Bowser = require("bowser"); // CommonJS
|
||||||
|
|
||||||
import * as Bowser from "bowser"; // TypeScript
|
import * as Bowser from "bowser"; // TypeScript
|
||||||
|
|
||||||
import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInterop enabled)</code></pre><p>By default, the exported version is the <em>ES5 transpiled version</em>, which <strong>do not</strong> include any polyfills.</p>
|
import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInterop enabled)
|
||||||
|
</code></pre>
|
||||||
|
<p>By default, the exported version is the <em>ES5 transpiled version</em>, which <strong>do not</strong> include any polyfills.</p>
|
||||||
<p>In case you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills.
|
<p>In case you don't use your own <code>babel-polyfill</code> you may need to have pre-built bundle with all needed polyfills.
|
||||||
So, for you it's suitable to require bowser like this: <code>require('bowser/bundled')</code>.
|
So, for you it's suitable to require bowser like this: <code>require('bowser/bundled')</code>.
|
||||||
As the result, you get a ES5 version of bowser with <code>babel-polyfill</code> bundled together.</p>
|
As the result, you get a ES5 version of bowser with <code>babel-polyfill</code> bundled together.</p>
|
||||||
<p>You may need to use the source files, so they will be available in the package as well.</p>
|
<p>You may need to use the source files, so they will be available in the package as well.</p>
|
||||||
<h2>Browser props detection</h2><p>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:</p>
|
<h2>Browser props detection</h2>
|
||||||
|
<p>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:</p>
|
||||||
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
|
|
||||||
console.log(`The current browser name is "${browser.getBrowserName()}"`);
|
console.log(`The current browser name is "${browser.getBrowserName()}"`);
|
||||||
// The current browser name is "Internet Explorer"</code></pre><p>or</p>
|
// The current browser name is "Internet Explorer"
|
||||||
|
</code></pre>
|
||||||
|
<p>or</p>
|
||||||
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
console.log(browser.getBrowser());
|
console.log(browser.getBrowser());
|
||||||
|
|
||||||
@ -83,7 +106,9 @@ console.log(browser.getBrowser());
|
|||||||
{
|
{
|
||||||
name: "Internet Explorer"
|
name: "Internet Explorer"
|
||||||
version: "11.0"
|
version: "11.0"
|
||||||
}</code></pre><p>or</p>
|
}
|
||||||
|
</code></pre>
|
||||||
|
<p>or</p>
|
||||||
<pre class="prettyprint source lang-javascript"><code>console.log(Bowser.parse(window.navigator.userAgent));
|
<pre class="prettyprint source lang-javascript"><code>console.log(Bowser.parse(window.navigator.userAgent));
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
@ -104,7 +129,10 @@ console.log(browser.getBrowser());
|
|||||||
name: "Trident"
|
name: "Trident"
|
||||||
version: "7.0"
|
version: "7.0"
|
||||||
}
|
}
|
||||||
}</code></pre><h2>Filtering browsers</h2><p>You could want to filter some particular browsers to provide any special support for them or make any workarounds.
|
}
|
||||||
|
</code></pre>
|
||||||
|
<h2>Filtering browsers</h2>
|
||||||
|
<p>You could want to filter some particular browsers to provide any special support for them or make any workarounds.
|
||||||
It could look like this:</p>
|
It could look like this:</p>
|
||||||
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
<pre class="prettyprint source lang-javascript"><code>const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
const isValidBrowser = browser.satisfies({
|
const isValidBrowser = browser.satisfies({
|
||||||
@ -125,24 +153,49 @@ const isValidBrowser = browser.satisfies({
|
|||||||
// or in general
|
// or in general
|
||||||
chrome: "~20.1.1432",
|
chrome: "~20.1.1432",
|
||||||
firefox: ">31",
|
firefox: ">31",
|
||||||
opera: ">=22"
|
opera: ">=22",
|
||||||
|
|
||||||
// also supports equality operator
|
// also supports equality operator
|
||||||
chrome: "=20.1.1432", // will match particular build only
|
chrome: "=20.1.1432", // will match particular build only
|
||||||
|
|
||||||
// and loose-equality operator
|
// and loose-equality operator
|
||||||
chrome: "~20" // will match any 20.* sub-version
|
chrome: "~20", // will match any 20.* sub-version
|
||||||
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
|
chrome: "~20.1" // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
|
||||||
});</code></pre><p>Settings for any particular OS or platform has more priority and redefines settings of standalone browsers.
|
});
|
||||||
|
</code></pre>
|
||||||
|
<p>Settings for any particular OS or platform has more priority and redefines settings of standalone browsers.
|
||||||
Thus, you can define OS or platform specific rules and they will have more priority in the end.</p>
|
Thus, you can define OS or platform specific rules and they will have more priority in the end.</p>
|
||||||
<p>More of API and possibilities you will find in the <code>docs</code> folder.</p>
|
<p>More of API and possibilities you will find in the <code>docs</code> folder.</p>
|
||||||
<h3>Browser names for <code>.satisfies()</code></h3><p>By default you are supposed to use the full browser name for <code>.satisfies</code>.
|
<h3>Browser names for <code>.satisfies()</code></h3>
|
||||||
|
<p>By default you are supposed to use the full browser name for <code>.satisfies</code>.
|
||||||
But, there's a short way to define a browser using short aliases. The full
|
But, there's a short way to define a browser using short aliases. The full
|
||||||
list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
|
list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
|
||||||
<h2>Similar Projects</h2><ul>
|
<h2>Similar Projects</h2>
|
||||||
|
<ul>
|
||||||
<li><a href="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li>
|
<li><a href="https://github.com/BigBadBleuCheese/Kong">Kong</a> - A C# port of Bowser.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>License</h2><p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article>
|
<h2>Contributors</h2>
|
||||||
|
<h3>Code Contributors</h3>
|
||||||
|
<p>This project exists thanks to all the people who contribute. [<a href="CONTRIBUTING.md">Contribute</a>].
|
||||||
|
<a href="https://github.com/lancedikson/bowser/graphs/contributors"><img src="https://opencollective.com/bowser/contributors.svg?width=890&button=false" /></a></p>
|
||||||
|
<h3>Financial Contributors</h3>
|
||||||
|
<p>Become a financial contributor and help us sustain our community. [<a href="https://opencollective.com/bowser/contribute">Contribute</a>]</p>
|
||||||
|
<h4>Individuals</h4>
|
||||||
|
<p><a href="https://opencollective.com/bowser"><img src="https://opencollective.com/bowser/individuals.svg?width=890"></a></p>
|
||||||
|
<h4>Organizations</h4>
|
||||||
|
<p>Support this project with your organization. Your logo will show up here with a link to your website. [<a href="https://opencollective.com/bowser/contribute">Contribute</a>]</p>
|
||||||
|
<p><a href="https://opencollective.com/bowser/organization/0/website"><img src="https://opencollective.com/bowser/organization/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/1/website"><img src="https://opencollective.com/bowser/organization/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/2/website"><img src="https://opencollective.com/bowser/organization/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/3/website"><img src="https://opencollective.com/bowser/organization/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/4/website"><img src="https://opencollective.com/bowser/organization/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/5/website"><img src="https://opencollective.com/bowser/organization/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/6/website"><img src="https://opencollective.com/bowser/organization/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/7/website"><img src="https://opencollective.com/bowser/organization/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/8/website"><img src="https://opencollective.com/bowser/organization/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/bowser/organization/9/website"><img src="https://opencollective.com/bowser/organization/9/avatar.svg"></a></p>
|
||||||
|
<h2>License</h2>
|
||||||
|
<p>Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.</p></article>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
@ -157,12 +210,14 @@ list of aliases can be found in <a href="src/constants.js">the file</a>.</p>
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -125,7 +126,7 @@ class Parser {
|
|||||||
parseBrowser() {
|
parseBrowser() {
|
||||||
this.parsedResult.browser = {};
|
this.parsedResult.browser = {};
|
||||||
|
|
||||||
const browserDescriptor = browserParsersList.find((_browser) => {
|
const browserDescriptor = Utils.find(browserParsersList, (_browser) => {
|
||||||
if (typeof _browser.test === 'function') {
|
if (typeof _browser.test === 'function') {
|
||||||
return _browser.test(this);
|
return _browser.test(this);
|
||||||
}
|
}
|
||||||
@ -208,7 +209,7 @@ class Parser {
|
|||||||
parseOS() {
|
parseOS() {
|
||||||
this.parsedResult.os = {};
|
this.parsedResult.os = {};
|
||||||
|
|
||||||
const os = osParsersList.find((_os) => {
|
const os = Utils.find(osParsersList, (_os) => {
|
||||||
if (typeof _os.test === 'function') {
|
if (typeof _os.test === 'function') {
|
||||||
return _os.test(this);
|
return _os.test(this);
|
||||||
}
|
}
|
||||||
@ -284,7 +285,7 @@ class Parser {
|
|||||||
parsePlatform() {
|
parsePlatform() {
|
||||||
this.parsedResult.platform = {};
|
this.parsedResult.platform = {};
|
||||||
|
|
||||||
const platform = platformParsersList.find((_platform) => {
|
const platform = Utils.find(platformParsersList, (_platform) => {
|
||||||
if (typeof _platform.test === 'function') {
|
if (typeof _platform.test === 'function') {
|
||||||
return _platform.test(this);
|
return _platform.test(this);
|
||||||
}
|
}
|
||||||
@ -335,7 +336,7 @@ class Parser {
|
|||||||
parseEngine() {
|
parseEngine() {
|
||||||
this.parsedResult.engine = {};
|
this.parsedResult.engine = {};
|
||||||
|
|
||||||
const engine = enginesParsersList.find((_engine) => {
|
const engine = Utils.find(enginesParsersList, (_engine) => {
|
||||||
if (typeof _engine.test === 'function') {
|
if (typeof _engine.test === 'function') {
|
||||||
return _engine.test(this);
|
return _engine.test(this);
|
||||||
}
|
}
|
||||||
@ -356,6 +357,7 @@ class Parser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse full information about the browser
|
* Parse full information about the browser
|
||||||
|
* @returns {Parser}
|
||||||
*/
|
*/
|
||||||
parse() {
|
parse() {
|
||||||
this.parseBrowser();
|
this.parseBrowser();
|
||||||
@ -371,7 +373,7 @@ class Parser {
|
|||||||
* @return {ParsedResult}
|
* @return {ParsedResult}
|
||||||
*/
|
*/
|
||||||
getResult() {
|
getResult() {
|
||||||
return Object.assign({}, this.parsedResult);
|
return Utils.assign({}, this.parsedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,12 +387,12 @@ class Parser {
|
|||||||
* Returns `undefined` when the browser is no described in the checkTree object.
|
* Returns `undefined` when the browser is no described in the checkTree object.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const browser = new Bowser(UA);
|
* const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
* if (browser.check({chrome: '>118.01.1322' }))
|
* if (browser.satisfies({chrome: '>118.01.1322' }))
|
||||||
* // or with os
|
* // or with os
|
||||||
* if (browser.check({windows: { chrome: '>118.01.1322' } }))
|
* if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
||||||
* // or with platforms
|
* // or with platforms
|
||||||
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
|
* if (browser.satisfies({desktop: { chrome: '>118.01.1322' } }))
|
||||||
*/
|
*/
|
||||||
satisfies(checkTree) {
|
satisfies(checkTree) {
|
||||||
const platformsAndOSes = {};
|
const platformsAndOSes = {};
|
||||||
@ -413,7 +415,7 @@ class Parser {
|
|||||||
|
|
||||||
if (platformsAndOSCounter > 0) {
|
if (platformsAndOSCounter > 0) {
|
||||||
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
||||||
const OSMatchingDefinition = platformsAndOSNames.find(name => (this.isOS(name)));
|
const OSMatchingDefinition = Utils.find(platformsAndOSNames, name => (this.isOS(name)));
|
||||||
|
|
||||||
if (OSMatchingDefinition) {
|
if (OSMatchingDefinition) {
|
||||||
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
||||||
@ -423,7 +425,10 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const platformMatchingDefinition = platformsAndOSNames.find(name => (this.isPlatform(name)));
|
const platformMatchingDefinition = Utils.find(
|
||||||
|
platformsAndOSNames,
|
||||||
|
name => (this.isPlatform(name)),
|
||||||
|
);
|
||||||
if (platformMatchingDefinition) {
|
if (platformMatchingDefinition) {
|
||||||
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
||||||
|
|
||||||
@ -435,7 +440,7 @@ class Parser {
|
|||||||
|
|
||||||
if (browsersCounter > 0) {
|
if (browsersCounter > 0) {
|
||||||
const browserNames = Object.keys(browsers);
|
const browserNames = Object.keys(browsers);
|
||||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name, true)));
|
const matchingDefinition = Utils.find(browserNames, name => (this.isBrowser(name, true)));
|
||||||
|
|
||||||
if (matchingDefinition !== void 0) {
|
if (matchingDefinition !== void 0) {
|
||||||
return this.compareVersion(browsers[matchingDefinition]);
|
return this.compareVersion(browsers[matchingDefinition]);
|
||||||
@ -445,15 +450,21 @@ class Parser {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
isBrowser(browserName, loosely = false) {
|
/**
|
||||||
const defaultBrowserName = this.getBrowserName();
|
* Check if the browser name equals the passed string
|
||||||
const possibleNames = [defaultBrowserName.toLowerCase()];
|
* @param browserName The string to compare with the browser name
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isBrowser(browserName, includingAlias = false) {
|
||||||
|
const defaultBrowserName = this.getBrowserName().toLowerCase();
|
||||||
|
let browserNameLower = browserName.toLowerCase();
|
||||||
|
const alias = Utils.getBrowserTypeByAlias(browserNameLower);
|
||||||
|
|
||||||
if (loosely) {
|
if (includingAlias && alias) {
|
||||||
possibleNames.push(Utils.getBrowserAlias(defaultBrowserName).toLowerCase());
|
browserNameLower = alias.toLowerCase();
|
||||||
}
|
}
|
||||||
|
return browserNameLower === defaultBrowserName;
|
||||||
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compareVersion(version) {
|
compareVersion(version) {
|
||||||
@ -508,10 +519,12 @@ class Parser {
|
|||||||
* Is anything? Check if the browser is called "anything",
|
* Is anything? Check if the browser is called "anything",
|
||||||
* the OS called "anything" or the platform called "anything"
|
* the OS called "anything" or the platform called "anything"
|
||||||
* @param {String} anything
|
* @param {String} anything
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
is(anything) {
|
is(anything, includingAlias = false) {
|
||||||
return this.isBrowser(anything) || this.isOS(anything) || this.isPlatform(anything);
|
return this.isBrowser(anything, includingAlias) || this.isOS(anything)
|
||||||
|
|| this.isPlatform(anything);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -539,12 +552,14 @@ export default Parser;
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,11 +1,20 @@
|
|||||||
function hideAllButCurrent(){
|
function hideAllButCurrent(){
|
||||||
//by default all submenut items are hidden
|
//by default all submenut items are hidden
|
||||||
$("nav > ul > li > ul li").hide();
|
//but we need to rehide them for search
|
||||||
|
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
|
||||||
|
parent.style.display = "none";
|
||||||
|
});
|
||||||
|
|
||||||
//only current page (if it exists) should be opened
|
//only current page (if it exists) should be opened
|
||||||
var file = window.location.pathname.split("/").pop();
|
var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
|
||||||
$("nav > ul > li > a[href^='"+file+"']").parent().find("> ul li").show();
|
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
|
||||||
}
|
var href = parent.attributes.href.value.replace(/\.html/, '');
|
||||||
$( document ).ready(function() {
|
if (file === href) {
|
||||||
hideAllButCurrent();
|
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
|
||||||
|
elem.style.display = "block";
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hideAllButCurrent();
|
||||||
12
docs/scripts/nav.js
Normal file
12
docs/scripts/nav.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
function scrollToNavItem() {
|
||||||
|
var path = window.location.href.split('/').pop().replace(/\.html/, '');
|
||||||
|
document.querySelectorAll('nav a').forEach(function(link) {
|
||||||
|
var href = link.attributes.href.value.replace(/\.html/, '');
|
||||||
|
if (path === href) {
|
||||||
|
link.scrollIntoView({block: 'center'});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToNavItem();
|
||||||
4
docs/scripts/polyfill.js
Normal file
4
docs/scripts/polyfill.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
//IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/
|
||||||
|
if (typeof(NodeList.prototype.forEach)!==typeof(alert)){
|
||||||
|
NodeList.prototype.forEach=Array.prototype.forEach;
|
||||||
|
}
|
||||||
@ -1,42 +1,83 @@
|
|||||||
$( document ).ready(function() {
|
|
||||||
jQuery.expr[':'].Contains = function(a,i,m){
|
var searchAttr = 'data-search-mode';
|
||||||
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
|
function contains(a,m){
|
||||||
|
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
//on search
|
//on search
|
||||||
$("#nav-search").on("keyup", function(event) {
|
document.getElementById("nav-search").addEventListener("keyup", function(event) {
|
||||||
var search = $(this).val();
|
var search = this.value.toUpperCase();
|
||||||
|
|
||||||
if (!search) {
|
if (!search) {
|
||||||
//no search, show all results
|
//no search, show all results
|
||||||
$("nav > ul > li").show();
|
document.documentElement.removeAttribute(searchAttr);
|
||||||
|
|
||||||
|
document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) {
|
||||||
|
elem.style.display = "block";
|
||||||
|
});
|
||||||
|
|
||||||
if (typeof hideAllButCurrent === "function"){
|
if (typeof hideAllButCurrent === "function"){
|
||||||
//let's do what ever collapse wants to do
|
//let's do what ever collapse wants to do
|
||||||
hideAllButCurrent();
|
hideAllButCurrent();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
//menu by default should be opened
|
//menu by default should be opened
|
||||||
$("nav > ul > li > ul li").show();
|
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
||||||
|
elem.style.display = "block";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
//we are searching
|
//we are searching
|
||||||
|
document.documentElement.setAttribute(searchAttr, '');
|
||||||
|
|
||||||
//show all parents
|
//show all parents
|
||||||
$("nav > ul > li").show();
|
document.querySelectorAll("nav > ul > li").forEach(function(elem) {
|
||||||
|
elem.style.display = "block";
|
||||||
|
});
|
||||||
//hide all results
|
//hide all results
|
||||||
$("nav > ul > li > ul li").hide();
|
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
||||||
|
elem.style.display = "none";
|
||||||
|
});
|
||||||
//show results matching filter
|
//show results matching filter
|
||||||
$("nav > ul > li > ul").find("a:Contains("+search+")").parent().show();
|
document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) {
|
||||||
|
if (!contains(elem.parentNode, search)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elem.parentNode.style.display = "block";
|
||||||
|
});
|
||||||
//hide parents without children
|
//hide parents without children
|
||||||
$("nav > ul > li").each(function(){
|
document.querySelectorAll("nav > ul > li").forEach(function(parent) {
|
||||||
if($(this).find("a:Contains("+search+")").length == 0 && $(this).children("ul").length === 0){
|
var countSearchA = 0;
|
||||||
|
parent.querySelectorAll("a").forEach(function(elem) {
|
||||||
|
if (contains(elem, search)) {
|
||||||
|
countSearchA++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var countUl = 0;
|
||||||
|
var countUlVisible = 0;
|
||||||
|
parent.querySelectorAll("ul").forEach(function(ulP) {
|
||||||
|
// count all elements that match the search
|
||||||
|
if (contains(ulP, search)) {
|
||||||
|
countUl++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// count all visible elements
|
||||||
|
var children = ulP.children
|
||||||
|
for (i=0; i<children.length; i++) {
|
||||||
|
var elem = children[i];
|
||||||
|
if (elem.style.display != "none") {
|
||||||
|
countUlVisible++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (countSearchA == 0 && countUl === 0){
|
||||||
//has no child at all and does not contain text
|
//has no child at all and does not contain text
|
||||||
$(this).hide();
|
parent.style.display = "none";
|
||||||
}
|
} else if(countSearchA == 0 && countUlVisible == 0){
|
||||||
else if($(this).find("a:Contains("+search+")").length == 0 && $(this).find("ul").children(':visible').length == 0){
|
|
||||||
//has no visible child and does not contain text
|
//has no visible child and does not contain text
|
||||||
$(this).hide();
|
parent.style.display = "none";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
@ -16,7 +16,6 @@ body {
|
|||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
font-family: 'Helvetica Neue', Helvetica, sans-serif;
|
font-family: 'Helvetica Neue', Helvetica, sans-serif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 160%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@ -41,8 +40,13 @@ article a:hover, article a:active {
|
|||||||
border-bottom-color: #222;
|
border-bottom-color: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article .description a {
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
p, ul, ol, blockquote {
|
p, ul, ol, blockquote {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
line-height: 160%;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
h1, h2, h3, h4, h5, h6 {
|
||||||
@ -65,6 +69,7 @@ h1.page-title {
|
|||||||
font-size: 48px;
|
font-size: 48px;
|
||||||
margin: 1em 30px;
|
margin: 1em 30px;
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
@ -179,6 +184,10 @@ nav #nav-search{
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav.wrap a{
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
nav h3 {
|
nav h3 {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@ -234,13 +243,12 @@ nav ul ul a:active {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nav h2 {
|
nav h2 {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
margin: 0;
|
margin: 10px 0 0 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav > h2 > a {
|
nav > h2 > a {
|
||||||
display: block;
|
|
||||||
margin: 10px 0 -10px;
|
margin: 10px 0 -10px;
|
||||||
color: #606 !important;
|
color: #606 !important;
|
||||||
}
|
}
|
||||||
@ -596,6 +604,15 @@ span.param-type, .params td .param-type, .param-type dd {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* nav level */
|
||||||
|
.level-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
html[data-search-mode] .level-hide {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@media only screen and (min-width: 320px) and (max-width: 680px) {
|
@media only screen and (min-width: 320px) and (max-width: 680px) {
|
||||||
body {
|
body {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
||||||
|
<script src="scripts/nav.js" defer></script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<nav >
|
<nav >
|
||||||
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bowser.html">Bowser</a><ul class='methods'><li data-type='method'><a href="Bowser.html#.getParser">getParser</a></li><li data-type='method'><a href="Bowser.html#.parse">parse</a></li></ul></li><li><a href="Parser.html">Parser</a><ul class='methods'><li data-type='method'><a href="Parser.html#getBrowser">getBrowser</a></li><li data-type='method'><a href="Parser.html#getBrowserName">getBrowserName</a></li><li data-type='method'><a href="Parser.html#getBrowserVersion">getBrowserVersion</a></li><li data-type='method'><a href="Parser.html#getEngine">getEngine</a></li><li data-type='method'><a href="Parser.html#getEngineName">getEngineName</a></li><li data-type='method'><a href="Parser.html#getOS">getOS</a></li><li data-type='method'><a href="Parser.html#getOSName">getOSName</a></li><li data-type='method'><a href="Parser.html#getOSVersion">getOSVersion</a></li><li data-type='method'><a href="Parser.html#getPlatform">getPlatform</a></li><li data-type='method'><a href="Parser.html#getPlatformType">getPlatformType</a></li><li data-type='method'><a href="Parser.html#getResult">getResult</a></li><li data-type='method'><a href="Parser.html#getUA">getUA</a></li><li data-type='method'><a href="Parser.html#is">is</a></li><li data-type='method'><a href="Parser.html#isBrowser">isBrowser</a></li><li data-type='method'><a href="Parser.html#parse">parse</a></li><li data-type='method'><a href="Parser.html#parseBrowser">parseBrowser</a></li><li data-type='method'><a href="Parser.html#parseEngine">parseEngine</a></li><li data-type='method'><a href="Parser.html#parseOS">parseOS</a></li><li data-type='method'><a href="Parser.html#parsePlatform">parsePlatform</a></li><li data-type='method'><a href="Parser.html#satisfies">satisfies</a></li><li data-type='method'><a href="Parser.html#some">some</a></li><li data-type='method'><a href="Parser.html#test">test</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#assign">assign</a></li><li><a href="global.html#find">find</a></li><li><a href="global.html#getAndroidVersionName">getAndroidVersionName</a></li><li><a href="global.html#getBrowserAlias">getBrowserAlias</a></li><li><a href="global.html#getBrowserTypeByAlias">getBrowserTypeByAlias</a></li><li><a href="global.html#getFirstMatch">getFirstMatch</a></li><li><a href="global.html#getMacOSVersionName">getMacOSVersionName</a></li><li><a href="global.html#getSecondMatch">getSecondMatch</a></li><li><a href="global.html#getVersionPrecision">getVersionPrecision</a></li><li><a href="global.html#map">map</a></li><li><a href="global.html#matchAndReturnConst">matchAndReturnConst</a></li></ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
@ -41,7 +42,7 @@
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<article>
|
<article>
|
||||||
<pre class="prettyprint source linenums"><code>import { BROWSER_ALIASES_MAP } from './constants.js';
|
<pre class="prettyprint source linenums"><code>import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
|
||||||
|
|
||||||
export default class Utils {
|
export default class Utils {
|
||||||
/**
|
/**
|
||||||
@ -96,6 +97,64 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get macOS version name
|
||||||
|
* 10.5 - Leopard
|
||||||
|
* 10.6 - Snow Leopard
|
||||||
|
* 10.7 - Lion
|
||||||
|
* 10.8 - Mountain Lion
|
||||||
|
* 10.9 - Mavericks
|
||||||
|
* 10.10 - Yosemite
|
||||||
|
* 10.11 - El Capitan
|
||||||
|
* 10.12 - Sierra
|
||||||
|
* 10.13 - High Sierra
|
||||||
|
* 10.14 - Mojave
|
||||||
|
* 10.15 - Catalina
|
||||||
|
* 11 - Big Sur
|
||||||
|
* 12 - Monterey
|
||||||
|
* 13 - Ventura
|
||||||
|
* 14 - Sonoma
|
||||||
|
* 15 - Sequoia
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* getMacOSVersionName("10.14") // 'Mojave'
|
||||||
|
*
|
||||||
|
* @param {string} version
|
||||||
|
* @return {string} versionName
|
||||||
|
*/
|
||||||
|
static getMacOSVersionName(version) {
|
||||||
|
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
|
||||||
|
v.push(0);
|
||||||
|
const major = v[0];
|
||||||
|
const minor = v[1];
|
||||||
|
|
||||||
|
if (major === 10) {
|
||||||
|
switch (minor) {
|
||||||
|
case 5: return 'Leopard';
|
||||||
|
case 6: return 'Snow Leopard';
|
||||||
|
case 7: return 'Lion';
|
||||||
|
case 8: return 'Mountain Lion';
|
||||||
|
case 9: return 'Mavericks';
|
||||||
|
case 10: return 'Yosemite';
|
||||||
|
case 11: return 'El Capitan';
|
||||||
|
case 12: return 'Sierra';
|
||||||
|
case 13: return 'High Sierra';
|
||||||
|
case 14: return 'Mojave';
|
||||||
|
case 15: return 'Catalina';
|
||||||
|
default: return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (major) {
|
||||||
|
case 11: return 'Big Sur';
|
||||||
|
case 12: return 'Monterey';
|
||||||
|
case 13: return 'Ventura';
|
||||||
|
case 14: return 'Sonoma';
|
||||||
|
case 15: return 'Sequoia';
|
||||||
|
default: return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Android version name
|
* Get Android version name
|
||||||
* 1.5 - Cupcake
|
* 1.5 - Cupcake
|
||||||
@ -112,7 +171,7 @@ export default class Utils {
|
|||||||
* 6.x - Marshmallow
|
* 6.x - Marshmallow
|
||||||
* 7.x - Nougat
|
* 7.x - Nougat
|
||||||
* 8.x - Oreo
|
* 8.x - Oreo
|
||||||
* 9.x - ?
|
* 9.x - Pie
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* getAndroidVersionName("7.0") // 'Nougat'
|
* getAndroidVersionName("7.0") // 'Nougat'
|
||||||
@ -137,6 +196,7 @@ export default class Utils {
|
|||||||
if (v[0] === 6) return 'Marshmallow';
|
if (v[0] === 6) return 'Marshmallow';
|
||||||
if (v[0] === 7) return 'Nougat';
|
if (v[0] === 7) return 'Nougat';
|
||||||
if (v[0] === 8) return 'Oreo';
|
if (v[0] === 8) return 'Oreo';
|
||||||
|
if (v[0] === 9) return 'Pie';
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +272,8 @@ export default class Utils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,6 +295,54 @@ export default class Utils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array::find polyfill
|
||||||
|
*
|
||||||
|
* @param {Array} arr
|
||||||
|
* @param {Function} predicate
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
static find(arr, predicate) {
|
||||||
|
let i;
|
||||||
|
let l;
|
||||||
|
if (Array.prototype.find) {
|
||||||
|
return Array.prototype.find.call(arr, predicate);
|
||||||
|
}
|
||||||
|
for (i = 0, l = arr.length; i < l; i += 1) {
|
||||||
|
const value = arr[i];
|
||||||
|
if (predicate(value, i)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object::assign polyfill
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {Object} ...objs
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
static assign(obj, ...assigners) {
|
||||||
|
const result = obj;
|
||||||
|
let i;
|
||||||
|
let l;
|
||||||
|
if (Object.assign) {
|
||||||
|
return Object.assign(obj, ...assigners);
|
||||||
|
}
|
||||||
|
for (i = 0, l = assigners.length; i < l; i += 1) {
|
||||||
|
const assigner = assigners[i];
|
||||||
|
if (typeof assigner === 'object' && assigner !== null) {
|
||||||
|
const keys = Object.keys(assigner);
|
||||||
|
keys.forEach((key) => {
|
||||||
|
result[key] = assigner[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get short version/alias for a browser name
|
* Get short version/alias for a browser name
|
||||||
*
|
*
|
||||||
@ -245,6 +355,19 @@ export default class Utils {
|
|||||||
static getBrowserAlias(browserName) {
|
static getBrowserAlias(browserName) {
|
||||||
return BROWSER_ALIASES_MAP[browserName];
|
return BROWSER_ALIASES_MAP[browserName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get short version/alias for a browser name
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* getBrowserAlias('edge') // Microsoft Edge
|
||||||
|
*
|
||||||
|
* @param {string} browserAlias
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
static getBrowserTypeByAlias(browserAlias) {
|
||||||
|
return BROWSER_MAP[browserAlias] || '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</article>
|
</article>
|
||||||
@ -260,12 +383,14 @@ export default class Utils {
|
|||||||
<br class="clear">
|
<br class="clear">
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Apr 07 2019 11:48:14 GMT+0300 (EEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Sep 12 2020 11:21:13 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>prettyPrint();</script>
|
<script>prettyPrint();</script>
|
||||||
|
<script src="scripts/polyfill.js"></script>
|
||||||
<script src="scripts/linenumber.js"></script>
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
113
index.d.ts
vendored
113
index.d.ts
vendored
@ -1,12 +1,11 @@
|
|||||||
// Type definitions for Bowser v2
|
// Type definitions for Bowser v2
|
||||||
// Project: https://github.com/lancedikson/bowser
|
// Project: https://github.com/bowser-js/bowser
|
||||||
// Definitions by: Alexander P. Cerutti <https://github.com/alexandercerutti>,
|
// Definitions by: Alexander P. Cerutti <https://github.com/alexandercerutti>,
|
||||||
|
|
||||||
export = Bowser;
|
export = Bowser;
|
||||||
export as namespace Bowser;
|
export as namespace Bowser;
|
||||||
|
|
||||||
declare namespace Bowser {
|
declare namespace Bowser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Parser instance
|
* Creates a Parser instance
|
||||||
* @param {string} UA - User agent string
|
* @param {string} UA - User agent string
|
||||||
@ -22,11 +21,26 @@ declare namespace Bowser {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function parse(UA: string): Parser.ParsedResult;
|
function parse(UA: string): Parser.ParsedResult;
|
||||||
}
|
|
||||||
|
|
||||||
declare namespace Parser {
|
/**
|
||||||
class Parser {
|
* Constants exposed via bowser getters
|
||||||
constructor(UA: string, skipParsing?: boolean);
|
*/
|
||||||
|
const BROWSER_MAP: Record<string, string>;
|
||||||
|
const ENGINE_MAP: Record<string, string>;
|
||||||
|
const OS_MAP: Record<string, string>;
|
||||||
|
const PLATFORMS_MAP: Record<string, string>;
|
||||||
|
|
||||||
|
namespace Parser {
|
||||||
|
interface Parser {
|
||||||
|
constructor(UA: string, skipParsing?: boolean): Parser.Parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the version is equals the browser version
|
||||||
|
* @param version The string to compare with the browser version
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
compareVersion(version: string): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed browser object
|
* Get parsed browser object
|
||||||
@ -37,17 +51,18 @@ declare namespace Parser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get browser's name
|
* Get browser's name
|
||||||
|
* @param {Boolean} [toLowerCase] return lower-cased value
|
||||||
* @return {String} Browser's name or an empty string
|
* @return {String} Browser's name or an empty string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBrowserName(): string;
|
getBrowserName(toLowerCase?: boolean): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get browser's version
|
* Get browser's version
|
||||||
* @return {String} version of browser
|
* @return {String} version of browser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBrowserVersion(): string;
|
getBrowserVersion(): string | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get OS
|
* Get OS
|
||||||
@ -98,6 +113,13 @@ declare namespace Parser {
|
|||||||
|
|
||||||
getEngine(): EngineDetails;
|
getEngine(): EngineDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parsed engine's name
|
||||||
|
* @returns {String} Engine's name or an empty string
|
||||||
|
*/
|
||||||
|
|
||||||
|
getEngineName(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed result
|
* Get parsed result
|
||||||
* @return {ParsedResult}
|
* @return {ParsedResult}
|
||||||
@ -116,16 +138,51 @@ declare namespace Parser {
|
|||||||
* Is anything? Check if the browser is called "anything",
|
* Is anything? Check if the browser is called "anything",
|
||||||
* the OS called "anything" or the platform called "anything"
|
* the OS called "anything" or the platform called "anything"
|
||||||
* @param {String} anything
|
* @param {String} anything
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
is(anything: any): boolean;
|
is(anything: any, includingAlias?: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the browser name equals the passed string
|
||||||
|
* @param browserName The string to compare with the browser name
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isBrowser(browserName: string, includingAlias?: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the engine name equals the passed string
|
||||||
|
* @param engineName The string to compare with the engine name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isEngine(engineName: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the OS name equals the passed string
|
||||||
|
* @param OSName The string to compare with the OS name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isOS(OSName: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the platform name equals the passed string
|
||||||
|
* @param platformName The string to compare with the platform name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isPlatform(platformName: string): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse full information about the browser
|
* Parse full information about the browser
|
||||||
|
* @returns {Parser.Parser}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parse(): void;
|
parse(): Parser.Parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed browser object
|
* Get parsed browser object
|
||||||
@ -177,7 +234,40 @@ declare namespace Parser {
|
|||||||
satisfies(checkTree: checkTree): boolean | undefined;
|
satisfies(checkTree: checkTree): boolean | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any of the given values satifies `.is(anything)`
|
* Check if the browser name equals the passed string
|
||||||
|
* @param {string} browserName The string to compare with the browser name
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isBrowser(browserName: string, includingAlias?: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the engine name equals the passed string
|
||||||
|
* @param {string} engineName The string to compare with the engine name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isEngine(engineName: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the platform type equals the passed string
|
||||||
|
* @param {string} platformType The string to compare with the platform type
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isPlatform(platformType: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the OS name equals the passed string
|
||||||
|
* @param {string} osName The string to compare with the OS name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
|
isOS(osName: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if any of the given values satisfies `.is(anything)`
|
||||||
* @param {string[]} anythings
|
* @param {string[]} anythings
|
||||||
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
|
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -222,3 +312,4 @@ declare namespace Parser {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
17979
package-lock.json
generated
17979
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "bowser",
|
"name": "bowser",
|
||||||
"version": "2.2.1",
|
|
||||||
"description": "Lightweight browser detector",
|
"description": "Lightweight browser detector",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"browser",
|
"browser",
|
||||||
@ -12,43 +11,52 @@
|
|||||||
"ender",
|
"ender",
|
||||||
"sniff"
|
"sniff"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/lancedikson/bowser",
|
"homepage": "https://github.com/bowser-js/bowser",
|
||||||
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
"name": "Denis Demchenko",
|
"name": "Denis Demchenko",
|
||||||
"url": "http://twitter.com/lancedikson"
|
"url": "http://twitter.com/lancedikson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Naor Peled",
|
||||||
|
"url": "https://github.com/naorpeled"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "es5.js",
|
"main": "es5.js",
|
||||||
|
"browser": "es5.js",
|
||||||
|
"module": "src/bowser.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/lancedikson/bowser.git"
|
"url": "git+https://github.com/bowser-js/bowser.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.2.3",
|
"@babel/cli": "^7.11.6",
|
||||||
"@babel/core": "^7.2.2",
|
"@babel/core": "^7.8.0",
|
||||||
"@babel/polyfill": "^7.2.5",
|
"@babel/polyfill": "^7.8.3",
|
||||||
"@babel/preset-env": "^7.2.3",
|
"@babel/preset-env": "^7.8.2",
|
||||||
"@babel/register": "^7.0.0",
|
"@babel/register": "^7.8.3",
|
||||||
"ava": "^1.1.0",
|
"ava": "^3.0.0",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.3",
|
||||||
"babel-loader": "^8.0.5",
|
"babel-loader": "^8.0.6",
|
||||||
"babel-plugin-add-module-exports": "^1.0.0",
|
"babel-plugin-add-module-exports": "^1.0.2",
|
||||||
"babel-plugin-istanbul": "^5.1.1",
|
"babel-plugin-istanbul": "^6.0.0",
|
||||||
"coveralls": "^3.0.2",
|
"compression-webpack-plugin": "^4.0.0",
|
||||||
"docdash": "^1.0.0",
|
"coveralls": "^3.0.6",
|
||||||
"eslint": "^5.4.0",
|
"docdash": "^1.1.1",
|
||||||
"eslint-config-airbnb-base": "^13.1.0",
|
"eslint": "^6.5.1",
|
||||||
"eslint-plugin-ava": "^5.1.0",
|
"eslint-config-airbnb-base": "^13.2.0",
|
||||||
"eslint-plugin-import": "^2.14.0",
|
"eslint-plugin-ava": "^10.0.0",
|
||||||
"gh-pages": "^2.0.1",
|
"eslint-plugin-import": "^2.18.2",
|
||||||
"jsdoc": "^3.5.5",
|
"gh-pages": "^3.0.0",
|
||||||
"nyc": "^13.2.0",
|
"jsdoc": "^3.6.3",
|
||||||
"sinon": "^6.1.5",
|
"nyc": "^15.0.0",
|
||||||
"testem": "^2.9.3",
|
"sinon": "^9.0.0",
|
||||||
"webpack": "^4.28.4",
|
"testem": "^3.0.0",
|
||||||
"webpack-cli": "^3.2.1",
|
"webpack": "^4.41.0",
|
||||||
|
"webpack-bundle-analyzer": "^3.5.2",
|
||||||
|
"webpack-cli": "^3.3.9",
|
||||||
"yamljs": "^0.3.0"
|
"yamljs": "^0.3.0"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
@ -57,21 +65,23 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/lancedikson/bowser/issues"
|
"url": "https://github.com/bowser-js/bowser/issues"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.config.js",
|
"build": "webpack --config webpack.config.js",
|
||||||
"deploy": "jsdoc -c jsdoc.json && gh-pages --dist docs --dest docs",
|
"generate-and-deploy-docs": "npm run generate-docs && gh-pages --dist docs --dest docs",
|
||||||
|
"watch": "webpack --watch --config webpack.config.js",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"lint": "eslint ./src",
|
"lint:check": "eslint ./src",
|
||||||
|
"lint:fix": "eslint --fix ./src",
|
||||||
"testem": "testem",
|
"testem": "testem",
|
||||||
"test": "nyc --reporter=html --reporter=text ava",
|
"test": "nyc --reporter=html --reporter=text ava",
|
||||||
"test:watch": "ava --watch",
|
"test:watch": "ava --watch",
|
||||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||||
"docs": "jsdoc -c jsdoc.json"
|
"generate-docs": "jsdoc -c jsdoc.json"
|
||||||
},
|
},
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
/*!
|
/*!
|
||||||
* Bowser - a browser detector
|
* Bowser - a browser detector
|
||||||
* https://github.com/lancedikson/bowser
|
* https://github.com/bowser-js/bowser
|
||||||
* MIT License | (c) Dustin Diaz 2012-2015
|
* MIT License | (c) Dustin Diaz 2012-2015
|
||||||
* MIT License | (c) Denis Demchenko 2015-2017
|
* MIT License | (c) Denis Demchenko 2015-2019
|
||||||
*/
|
*/
|
||||||
import Parser from './parser.js';
|
import Parser from './parser.js';
|
||||||
|
import {
|
||||||
|
BROWSER_MAP,
|
||||||
|
ENGINE_MAP,
|
||||||
|
OS_MAP,
|
||||||
|
PLATFORMS_MAP,
|
||||||
|
} from './constants.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bowser class.
|
* Bowser class.
|
||||||
@ -12,13 +18,18 @@ import Parser from './parser.js';
|
|||||||
* It's supposed to work with collections of {@link Parser} instances
|
* It's supposed to work with collections of {@link Parser} instances
|
||||||
* rather then solve one-instance problems.
|
* rather then solve one-instance problems.
|
||||||
* All the one-instance stuff is located in Parser class.
|
* All the one-instance stuff is located in Parser class.
|
||||||
|
*
|
||||||
|
* @class
|
||||||
|
* @classdesc Bowser is a static object, that provides an API to the Parsers
|
||||||
|
* @hideconstructor
|
||||||
*/
|
*/
|
||||||
class Bowser {
|
class Bowser {
|
||||||
/**
|
/**
|
||||||
* Creates a {@link module:parser:Parser} instance
|
* Creates a {@link Parser} instance
|
||||||
*
|
*
|
||||||
* @param {String} UA UserAgent string
|
* @param {String} UA UserAgent string
|
||||||
* @param {Boolean} [skipParsing=false] same as skipParsing for {@link Parser}
|
* @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
|
||||||
|
* explicitly. Same as `skipParsing` for {@link Parser}.
|
||||||
* @returns {Parser}
|
* @returns {Parser}
|
||||||
* @throws {Error} when UA is not a String
|
* @throws {Error} when UA is not a String
|
||||||
*
|
*
|
||||||
@ -45,6 +56,22 @@ class Bowser {
|
|||||||
static parse(UA) {
|
static parse(UA) {
|
||||||
return (new Parser(UA)).getResult();
|
return (new Parser(UA)).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get BROWSER_MAP() {
|
||||||
|
return BROWSER_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get ENGINE_MAP() {
|
||||||
|
return ENGINE_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get OS_MAP() {
|
||||||
|
return OS_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get PLATFORMS_MAP() {
|
||||||
|
return PLATFORMS_MAP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Bowser;
|
export default Bowser;
|
||||||
|
|||||||
133
src/constants.js
133
src/constants.js
@ -1,42 +1,169 @@
|
|||||||
// NOTE: this list must be up-to-date with browsers listed in
|
// NOTE: this list must be up-to-date with browsers listed in
|
||||||
// test/acceptance/useragentstrings.yml
|
// test/acceptance/useragentstrings.yml
|
||||||
const BROWSER_ALIASES_MAP = {
|
export const BROWSER_ALIASES_MAP = {
|
||||||
|
AmazonBot: 'amazonbot',
|
||||||
'Amazon Silk': 'amazon_silk',
|
'Amazon Silk': 'amazon_silk',
|
||||||
'Android Browser': 'android',
|
'Android Browser': 'android',
|
||||||
|
BaiduSpider: 'baiduspider',
|
||||||
Bada: 'bada',
|
Bada: 'bada',
|
||||||
|
BingCrawler: 'bingcrawler',
|
||||||
BlackBerry: 'blackberry',
|
BlackBerry: 'blackberry',
|
||||||
|
'ChatGPT-User': 'chatgpt_user',
|
||||||
Chrome: 'chrome',
|
Chrome: 'chrome',
|
||||||
|
ClaudeBot: 'claudebot',
|
||||||
Chromium: 'chromium',
|
Chromium: 'chromium',
|
||||||
|
Diffbot: 'diffbot',
|
||||||
|
DuckDuckBot: 'duckduckbot',
|
||||||
|
Electron: 'electron',
|
||||||
Epiphany: 'epiphany',
|
Epiphany: 'epiphany',
|
||||||
|
FacebookExternalHit: 'facebookexternalhit',
|
||||||
Firefox: 'firefox',
|
Firefox: 'firefox',
|
||||||
Focus: 'focus',
|
Focus: 'focus',
|
||||||
Generic: 'generic',
|
Generic: 'generic',
|
||||||
|
'Google Search': 'google_search',
|
||||||
Googlebot: 'googlebot',
|
Googlebot: 'googlebot',
|
||||||
|
GPTBot: 'gptbot',
|
||||||
'Internet Explorer': 'ie',
|
'Internet Explorer': 'ie',
|
||||||
|
InternetArchiveCrawler: 'internetarchivecrawler',
|
||||||
'K-Meleon': 'k_meleon',
|
'K-Meleon': 'k_meleon',
|
||||||
|
LibreWolf: 'librewolf',
|
||||||
Maxthon: 'maxthon',
|
Maxthon: 'maxthon',
|
||||||
|
'Meta-ExternalAds': 'meta_externalads',
|
||||||
|
'Meta-ExternalAgent': 'meta_externalagent',
|
||||||
|
'Meta-ExternalFetcher': 'meta_externalfetcher',
|
||||||
|
'Meta-WebIndexer': 'meta_webindexer',
|
||||||
'Microsoft Edge': 'edge',
|
'Microsoft Edge': 'edge',
|
||||||
'MZ Browser': 'mz',
|
'MZ Browser': 'mz',
|
||||||
'NAVER Whale Browser': 'naver',
|
'NAVER Whale Browser': 'naver',
|
||||||
|
'OAI-SearchBot': 'oai_searchbot',
|
||||||
|
Omgilibot: 'omgilibot',
|
||||||
Opera: 'opera',
|
Opera: 'opera',
|
||||||
'Opera Coast': 'opera_coast',
|
'Opera Coast': 'opera_coast',
|
||||||
|
'Pale Moon': 'pale_moon',
|
||||||
|
PerplexityBot: 'perplexitybot',
|
||||||
|
'Perplexity-User': 'perplexity_user',
|
||||||
PhantomJS: 'phantomjs',
|
PhantomJS: 'phantomjs',
|
||||||
|
PingdomBot: 'pingdombot',
|
||||||
Puffin: 'puffin',
|
Puffin: 'puffin',
|
||||||
|
QQ: 'qq',
|
||||||
|
QQLite: 'qqlite',
|
||||||
QupZilla: 'qupzilla',
|
QupZilla: 'qupzilla',
|
||||||
|
Roku: 'roku',
|
||||||
Safari: 'safari',
|
Safari: 'safari',
|
||||||
Sailfish: 'sailfish',
|
Sailfish: 'sailfish',
|
||||||
'Samsung Internet for Android': 'samsung_internet',
|
'Samsung Internet for Android': 'samsung_internet',
|
||||||
SeaMonkey: 'seamonkey',
|
SeaMonkey: 'seamonkey',
|
||||||
Sleipnir: 'sleipnir',
|
Sleipnir: 'sleipnir',
|
||||||
|
'Sogou Browser': 'sogou',
|
||||||
Swing: 'swing',
|
Swing: 'swing',
|
||||||
Tizen: 'tizen',
|
Tizen: 'tizen',
|
||||||
'UC Browser': 'uc',
|
'UC Browser': 'uc',
|
||||||
Vivaldi: 'vivaldi',
|
Vivaldi: 'vivaldi',
|
||||||
'WebOS Browser': 'webos',
|
'WebOS Browser': 'webos',
|
||||||
WeChat: 'wechat',
|
WeChat: 'wechat',
|
||||||
|
YahooSlurp: 'yahooslurp',
|
||||||
'Yandex Browser': 'yandex',
|
'Yandex Browser': 'yandex',
|
||||||
|
YandexBot: 'yandexbot',
|
||||||
|
YouBot: 'youbot',
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
export const BROWSER_MAP = {
|
||||||
BROWSER_ALIASES_MAP,
|
amazonbot: 'AmazonBot',
|
||||||
|
amazon_silk: 'Amazon Silk',
|
||||||
|
android: 'Android Browser',
|
||||||
|
baiduspider: 'BaiduSpider',
|
||||||
|
bada: 'Bada',
|
||||||
|
bingcrawler: 'BingCrawler',
|
||||||
|
blackberry: 'BlackBerry',
|
||||||
|
chatgpt_user: 'ChatGPT-User',
|
||||||
|
chrome: 'Chrome',
|
||||||
|
claudebot: 'ClaudeBot',
|
||||||
|
chromium: 'Chromium',
|
||||||
|
diffbot: 'Diffbot',
|
||||||
|
duckduckbot: 'DuckDuckBot',
|
||||||
|
edge: 'Microsoft Edge',
|
||||||
|
electron: 'Electron',
|
||||||
|
epiphany: 'Epiphany',
|
||||||
|
facebookexternalhit: 'FacebookExternalHit',
|
||||||
|
firefox: 'Firefox',
|
||||||
|
focus: 'Focus',
|
||||||
|
generic: 'Generic',
|
||||||
|
google_search: 'Google Search',
|
||||||
|
googlebot: 'Googlebot',
|
||||||
|
gptbot: 'GPTBot',
|
||||||
|
ie: 'Internet Explorer',
|
||||||
|
internetarchivecrawler: 'InternetArchiveCrawler',
|
||||||
|
k_meleon: 'K-Meleon',
|
||||||
|
librewolf: 'LibreWolf',
|
||||||
|
maxthon: 'Maxthon',
|
||||||
|
meta_externalads: 'Meta-ExternalAds',
|
||||||
|
meta_externalagent: 'Meta-ExternalAgent',
|
||||||
|
meta_externalfetcher: 'Meta-ExternalFetcher',
|
||||||
|
meta_webindexer: 'Meta-WebIndexer',
|
||||||
|
mz: 'MZ Browser',
|
||||||
|
naver: 'NAVER Whale Browser',
|
||||||
|
oai_searchbot: 'OAI-SearchBot',
|
||||||
|
omgilibot: 'Omgilibot',
|
||||||
|
opera: 'Opera',
|
||||||
|
opera_coast: 'Opera Coast',
|
||||||
|
pale_moon: 'Pale Moon',
|
||||||
|
perplexitybot: 'PerplexityBot',
|
||||||
|
perplexity_user: 'Perplexity-User',
|
||||||
|
phantomjs: 'PhantomJS',
|
||||||
|
pingdombot: 'PingdomBot',
|
||||||
|
puffin: 'Puffin',
|
||||||
|
qq: 'QQ Browser',
|
||||||
|
qqlite: 'QQ Browser Lite',
|
||||||
|
qupzilla: 'QupZilla',
|
||||||
|
roku: 'Roku',
|
||||||
|
safari: 'Safari',
|
||||||
|
sailfish: 'Sailfish',
|
||||||
|
samsung_internet: 'Samsung Internet for Android',
|
||||||
|
seamonkey: 'SeaMonkey',
|
||||||
|
sleipnir: 'Sleipnir',
|
||||||
|
sogou: 'Sogou Browser',
|
||||||
|
swing: 'Swing',
|
||||||
|
tizen: 'Tizen',
|
||||||
|
uc: 'UC Browser',
|
||||||
|
vivaldi: 'Vivaldi',
|
||||||
|
webos: 'WebOS Browser',
|
||||||
|
wechat: 'WeChat',
|
||||||
|
yahooslurp: 'YahooSlurp',
|
||||||
|
yandex: 'Yandex Browser',
|
||||||
|
yandexbot: 'YandexBot',
|
||||||
|
youbot: 'YouBot',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PLATFORMS_MAP = {
|
||||||
|
bot: 'bot',
|
||||||
|
desktop: 'desktop',
|
||||||
|
mobile: 'mobile',
|
||||||
|
tablet: 'tablet',
|
||||||
|
tv: 'tv',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const OS_MAP = {
|
||||||
|
Android: 'Android',
|
||||||
|
Bada: 'Bada',
|
||||||
|
BlackBerry: 'BlackBerry',
|
||||||
|
ChromeOS: 'Chrome OS',
|
||||||
|
HarmonyOS: 'HarmonyOS',
|
||||||
|
iOS: 'iOS',
|
||||||
|
Linux: 'Linux',
|
||||||
|
MacOS: 'macOS',
|
||||||
|
PlayStation4: 'PlayStation 4',
|
||||||
|
Roku: 'Roku',
|
||||||
|
Tizen: 'Tizen',
|
||||||
|
WebOS: 'WebOS',
|
||||||
|
Windows: 'Windows',
|
||||||
|
WindowsPhone: 'Windows Phone',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ENGINE_MAP = {
|
||||||
|
Blink: 'Blink',
|
||||||
|
EdgeHTML: 'EdgeHTML',
|
||||||
|
Gecko: 'Gecko',
|
||||||
|
Presto: 'Presto',
|
||||||
|
Trident: 'Trident',
|
||||||
|
WebKit: 'WebKit',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -28,6 +28,227 @@ import Utils from './utils.js';
|
|||||||
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
||||||
|
|
||||||
const browsersList = [
|
const browsersList = [
|
||||||
|
/* GPTBot */
|
||||||
|
{
|
||||||
|
test: [/gptbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'GPTBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/gptbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ChatGPT-User */
|
||||||
|
{
|
||||||
|
test: [/chatgpt-user/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'ChatGPT-User',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/chatgpt-user\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* OAI-SearchBot */
|
||||||
|
{
|
||||||
|
test: [/oai-searchbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'OAI-SearchBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/oai-searchbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ClaudeBot */
|
||||||
|
{
|
||||||
|
test: [/claudebot/i, /claude-web/i, /claude-user/i, /claude-searchbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'ClaudeBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:claudebot|claude-web|claude-user|claude-searchbot)\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Omgilibot */
|
||||||
|
{
|
||||||
|
test: [/omgilibot/i, /webzio-extended/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Omgilibot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:omgilibot|webzio-extended)\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Diffbot */
|
||||||
|
{
|
||||||
|
test: [/diffbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Diffbot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/diffbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* PerplexityBot */
|
||||||
|
{
|
||||||
|
test: [/perplexitybot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'PerplexityBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/perplexitybot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Perplexity-User */
|
||||||
|
{
|
||||||
|
test: [/perplexity-user/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Perplexity-User',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/perplexity-user\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* YouBot */
|
||||||
|
{
|
||||||
|
test: [/youbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'YouBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/youbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-WebIndexer */
|
||||||
|
{
|
||||||
|
test: [/meta-webindexer/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Meta-WebIndexer',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/meta-webindexer\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalAds */
|
||||||
|
{
|
||||||
|
test: [/meta-externalads/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Meta-ExternalAds',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/meta-externalads\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalAgent */
|
||||||
|
{
|
||||||
|
test: [/meta-externalagent/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Meta-ExternalAgent',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/meta-externalagent\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalFetcher */
|
||||||
|
{
|
||||||
|
test: [/meta-externalfetcher/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Meta-ExternalFetcher',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/meta-externalfetcher\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Googlebot */
|
/* Googlebot */
|
||||||
{
|
{
|
||||||
test: [/googlebot/i],
|
test: [/googlebot/i],
|
||||||
@ -45,6 +266,131 @@ const browsersList = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* AmazonBot */
|
||||||
|
{
|
||||||
|
test: [/amazonbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'AmazonBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/amazonbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* BingCrawler */
|
||||||
|
{
|
||||||
|
test: [/bingbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'BingCrawler',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/bingbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* BaiduSpider */
|
||||||
|
{
|
||||||
|
test: [/baiduspider/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'BaiduSpider',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/baiduspider\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* DuckDuckBot */
|
||||||
|
{
|
||||||
|
test: [/duckduckbot/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'DuckDuckBot',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/duckduckbot\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* InternetArchiveCrawler */
|
||||||
|
{
|
||||||
|
test: [/ia_archiver/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'InternetArchiveCrawler',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/ia_archiver\/(\d+(\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* FacebookExternalHit */
|
||||||
|
{
|
||||||
|
test: [/facebookexternalhit/i, /facebookcatalog/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
name: 'FacebookExternalHit',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* YahooSlurp */
|
||||||
|
{
|
||||||
|
test: [/yahoo!?[\s/]*slurp/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
name: 'YahooSlurp',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* YandexBot */
|
||||||
|
{
|
||||||
|
test: [/yandexbot/i, /yandexmobilebot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
name: 'YandexBot',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* PingdomBot */
|
||||||
|
{
|
||||||
|
test: [/pingdom/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
name: 'PingdomBot',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Opera < 13.0 */
|
/* Opera < 13.0 */
|
||||||
{
|
{
|
||||||
test: [/opera/i],
|
test: [/opera/i],
|
||||||
@ -108,6 +454,21 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/PaleMoon/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Pale Moon',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/MZBrowser/i],
|
test: [/MZBrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -168,6 +529,21 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/opt\/\d+(?:.?_?\d+)+/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Opera Touch',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/yabrowser/i],
|
test: [/yabrowser/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -288,6 +664,21 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/qqbrowser/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: (/qqbrowserlite/i).test(ua) ? 'QQ Browser Lite' : 'QQ Browser',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/msie|trident/i],
|
test: [/msie|trident/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -303,6 +694,22 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/\sedg\//i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Microsoft Edge',
|
||||||
|
};
|
||||||
|
|
||||||
|
const version = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/edg([ea]|ios)/i],
|
test: [/edg([ea]|ios)/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -485,6 +892,21 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/librewolf/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'LibreWolf',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:librewolf)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/firefox|iceweasel|fxios/i],
|
test: [/firefox|iceweasel|fxios/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -500,6 +922,54 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/electron/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Electron',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: [/sogoumobilebrowser/i, /metasr/i, /se 2\.[x]/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Sogou Browser',
|
||||||
|
};
|
||||||
|
const sogouMobileVersion = Utils.getFirstMatch(/(?:sogoumobilebrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
const chromiumVersion = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
const seVersion = Utils.getFirstMatch(/se ([\d.]+)x/i, ua);
|
||||||
|
const version = sogouMobileVersion || chromiumVersion || seVersion;
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: [/MiuiBrowser/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Miui',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: [/chromium/i],
|
test: [/chromium/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
@ -530,6 +1000,21 @@ const browsersList = [
|
|||||||
return browser;
|
return browser;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: [/GSA/i],
|
||||||
|
describe(ua) {
|
||||||
|
const browser = {
|
||||||
|
name: 'Google Search',
|
||||||
|
};
|
||||||
|
const version = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
browser.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Android Browser */
|
/* Android Browser */
|
||||||
{
|
{
|
||||||
@ -590,9 +1075,17 @@ const browsersList = [
|
|||||||
{
|
{
|
||||||
test: [/.*/i],
|
test: [/.*/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
|
/* Here we try to make sure that there are explicit details about the device
|
||||||
|
* in order to decide what regexp exactly we want to apply
|
||||||
|
* (as there is a specific decision based on that conclusion)
|
||||||
|
*/
|
||||||
|
const regexpWithoutDeviceSpec = /^(.*)\/(.*) /;
|
||||||
|
const regexpWithDeviceSpec = /^(.*)\/(.*)[ \t]\((.*)/;
|
||||||
|
const hasDeviceSpec = ua.search('\\(') !== -1;
|
||||||
|
const regexp = hasDeviceSpec ? regexpWithDeviceSpec : regexpWithoutDeviceSpec;
|
||||||
return {
|
return {
|
||||||
name: Utils.getFirstMatch(/^(.*)\/(.*) /, ua),
|
name: Utils.getFirstMatch(regexp, ua),
|
||||||
version: Utils.getSecondMatch(/^(.*)\/(.*) /, ua),
|
version: Utils.getSecondMatch(regexp, ua),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import Utils from './utils.js';
|
import Utils from './utils.js';
|
||||||
|
import { ENGINE_MAP } from './constants.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* More specific goes first
|
* More specific goes first
|
||||||
@ -10,9 +11,20 @@ export default [
|
|||||||
return parser.getBrowserName(true) === 'microsoft edge';
|
return parser.getBrowserName(true) === 'microsoft edge';
|
||||||
},
|
},
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
|
const isBlinkBased = /\sedg\//i.test(ua);
|
||||||
|
|
||||||
|
// return blink if it's blink-based one
|
||||||
|
if (isBlinkBased) {
|
||||||
return {
|
return {
|
||||||
name: 'EdgeHTML',
|
name: ENGINE_MAP.Blink,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise match the version and return EdgeHTML
|
||||||
|
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: ENGINE_MAP.EdgeHTML,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -23,7 +35,7 @@ export default [
|
|||||||
test: [/trident/i],
|
test: [/trident/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const engine = {
|
const engine = {
|
||||||
name: 'Trident',
|
name: ENGINE_MAP.Trident,
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
@ -43,7 +55,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const engine = {
|
const engine = {
|
||||||
name: 'Presto',
|
name: ENGINE_MAP.Presto,
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
@ -65,7 +77,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const engine = {
|
const engine = {
|
||||||
name: 'Gecko',
|
name: ENGINE_MAP.Gecko,
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
@ -83,7 +95,7 @@ export default [
|
|||||||
test: [/(apple)?webkit\/537\.36/i],
|
test: [/(apple)?webkit\/537\.36/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
name: 'Blink',
|
name: ENGINE_MAP.Blink,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -93,7 +105,7 @@ export default [
|
|||||||
test: [/(apple)?webkit/i],
|
test: [/(apple)?webkit/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const engine = {
|
const engine = {
|
||||||
name: 'WebKit',
|
name: ENGINE_MAP.WebKit,
|
||||||
};
|
};
|
||||||
|
|
||||||
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|||||||
@ -1,13 +1,26 @@
|
|||||||
import Utils from './utils.js';
|
import Utils from './utils.js';
|
||||||
|
import { OS_MAP } from './constants.js';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
/* Roku */
|
||||||
|
{
|
||||||
|
test: [/Roku\/DVP/],
|
||||||
|
describe(ua) {
|
||||||
|
const version = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
|
||||||
|
return {
|
||||||
|
name: OS_MAP.Roku,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Windows Phone */
|
/* Windows Phone */
|
||||||
{
|
{
|
||||||
test: [/windows phone/i],
|
test: [/windows phone/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
|
||||||
return {
|
return {
|
||||||
name: 'Windows Phone',
|
name: OS_MAP.WindowsPhone,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -21,22 +34,43 @@ export default [
|
|||||||
const versionName = Utils.getWindowsVersionName(version);
|
const versionName = Utils.getWindowsVersionName(version);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'Windows',
|
name: OS_MAP.Windows,
|
||||||
version,
|
version,
|
||||||
versionName,
|
versionName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* Firefox on iPad */
|
||||||
|
{
|
||||||
|
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
||||||
|
describe(ua) {
|
||||||
|
const result = {
|
||||||
|
name: OS_MAP.iOS,
|
||||||
|
};
|
||||||
|
const version = Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/, ua);
|
||||||
|
if (version) {
|
||||||
|
result.version = version;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* macOS */
|
/* macOS */
|
||||||
{
|
{
|
||||||
test: [/macintosh/i],
|
test: [/macintosh/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
|
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
|
||||||
return {
|
const versionName = Utils.getMacOSVersionName(version);
|
||||||
name: 'macOS',
|
|
||||||
|
const os = {
|
||||||
|
name: OS_MAP.MacOS,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
|
if (versionName) {
|
||||||
|
os.versionName = versionName;
|
||||||
|
}
|
||||||
|
return os;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -47,7 +81,19 @@ export default [
|
|||||||
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.');
|
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'iOS',
|
name: OS_MAP.iOS,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* HarmonyOS */
|
||||||
|
{
|
||||||
|
test: [/OpenHarmony/i],
|
||||||
|
describe(ua) {
|
||||||
|
const version = Utils.getFirstMatch(/OpenHarmony\s+(\d+(\.\d+)*)/i, ua);
|
||||||
|
return {
|
||||||
|
name: OS_MAP.HarmonyOS,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -64,7 +110,7 @@ export default [
|
|||||||
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
|
||||||
const versionName = Utils.getAndroidVersionName(version);
|
const versionName = Utils.getAndroidVersionName(version);
|
||||||
const os = {
|
const os = {
|
||||||
name: 'Android',
|
name: OS_MAP.Android,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
if (versionName) {
|
if (versionName) {
|
||||||
@ -80,7 +126,7 @@ export default [
|
|||||||
describe(ua) {
|
describe(ua) {
|
||||||
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
|
||||||
const os = {
|
const os = {
|
||||||
name: 'WebOS',
|
name: OS_MAP.WebOS,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (version && version.length) {
|
if (version && version.length) {
|
||||||
@ -99,7 +145,7 @@ export default [
|
|||||||
|| Utils.getFirstMatch(/\bbb(\d+)/i, ua);
|
|| Utils.getFirstMatch(/\bbb(\d+)/i, ua);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'BlackBerry',
|
name: OS_MAP.BlackBerry,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -112,7 +158,7 @@ export default [
|
|||||||
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'Bada',
|
name: OS_MAP.Bada,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -125,7 +171,7 @@ export default [
|
|||||||
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'Tizen',
|
name: OS_MAP.Tizen,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -136,7 +182,7 @@ export default [
|
|||||||
test: [/linux/i],
|
test: [/linux/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
name: 'Linux',
|
name: OS_MAP.Linux,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -146,7 +192,7 @@ export default [
|
|||||||
test: [/CrOS/],
|
test: [/CrOS/],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
name: 'Chrome OS',
|
name: OS_MAP.ChromeOS,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -157,7 +203,7 @@ export default [
|
|||||||
describe(ua) {
|
describe(ua) {
|
||||||
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
|
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
|
||||||
return {
|
return {
|
||||||
name: 'PlayStation 4',
|
name: OS_MAP.PlayStation4,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,11 +1,5 @@
|
|||||||
import Utils from './utils.js';
|
import Utils from './utils.js';
|
||||||
|
import { PLATFORMS_MAP } from './constants.js';
|
||||||
const TYPES_LABELS = {
|
|
||||||
tablet: 'tablet',
|
|
||||||
mobile: 'mobile',
|
|
||||||
desktop: 'desktop',
|
|
||||||
tv: 'tv',
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tablets go first since usually they have more specific
|
* Tablets go first since usually they have more specific
|
||||||
@ -18,19 +12,261 @@ export default [
|
|||||||
test: [/googlebot/i],
|
test: [/googlebot/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: 'bot',
|
type: PLATFORMS_MAP.bot,
|
||||||
vendor: 'Google',
|
vendor: 'Google',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* AmazonBot */
|
||||||
|
{
|
||||||
|
test: [/amazonbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Amazon',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* GPTBot */
|
||||||
|
{
|
||||||
|
test: [/gptbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'OpenAI',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ChatGPT-User */
|
||||||
|
{
|
||||||
|
test: [/chatgpt-user/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'OpenAI',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* OAI-SearchBot */
|
||||||
|
{
|
||||||
|
test: [/oai-searchbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'OpenAI',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Baidu */
|
||||||
|
{
|
||||||
|
test: [/baiduspider/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Baidu',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Bingbot */
|
||||||
|
{
|
||||||
|
test: [/bingbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Bing',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* DuckDuckBot */
|
||||||
|
{
|
||||||
|
test: [/duckduckbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'DuckDuckGo',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ClaudeBot */
|
||||||
|
{
|
||||||
|
test: [/claudebot/i, /claude-web/i, /claude-user/i, /claude-searchbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Anthropic',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Omgilibot */
|
||||||
|
{
|
||||||
|
test: [/omgilibot/i, /webzio-extended/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Webz.io',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Diffbot */
|
||||||
|
{
|
||||||
|
test: [/diffbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Diffbot',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* PerplexityBot */
|
||||||
|
{
|
||||||
|
test: [/perplexitybot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Perplexity AI',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Perplexity-User */
|
||||||
|
{
|
||||||
|
test: [/perplexity-user/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Perplexity AI',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* YouBot */
|
||||||
|
{
|
||||||
|
test: [/youbot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'You.com',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Internet Archive Crawler */
|
||||||
|
{
|
||||||
|
test: [/ia_archiver/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Internet Archive',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-WebIndexer */
|
||||||
|
{
|
||||||
|
test: [/meta-webindexer/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Meta',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalAds */
|
||||||
|
{
|
||||||
|
test: [/meta-externalads/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Meta',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalAgent */
|
||||||
|
{
|
||||||
|
test: [/meta-externalagent/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Meta',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta-ExternalFetcher */
|
||||||
|
{
|
||||||
|
test: [/meta-externalfetcher/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Meta',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Meta Web Crawler */
|
||||||
|
{
|
||||||
|
test: [/facebookexternalhit/i, /facebookcatalog/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Meta',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Yahoo! Slurp */
|
||||||
|
{
|
||||||
|
test: [/yahoo/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Yahoo',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Yandex */
|
||||||
|
{
|
||||||
|
test: [/yandexbot/i, /yandexmobilebot/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Yandex',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Pingdom */
|
||||||
|
{
|
||||||
|
test: [/pingdom/i],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.bot,
|
||||||
|
vendor: 'Pingdom',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Huawei */
|
/* Huawei */
|
||||||
{
|
{
|
||||||
test: [/huawei/i],
|
test: [/huawei/i],
|
||||||
describe(ua) {
|
describe(ua) {
|
||||||
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && 'Nova';
|
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && 'Nova';
|
||||||
const platform = {
|
const platform = {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
vendor: 'Huawei',
|
vendor: 'Huawei',
|
||||||
};
|
};
|
||||||
if (model) {
|
if (model) {
|
||||||
@ -45,7 +281,7 @@ export default [
|
|||||||
test: [/nexus\s*(?:7|8|9|10).*/i],
|
test: [/nexus\s*(?:7|8|9|10).*/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
vendor: 'Nexus',
|
vendor: 'Nexus',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -56,7 +292,19 @@ export default [
|
|||||||
test: [/ipad/i],
|
test: [/ipad/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
|
vendor: 'Apple',
|
||||||
|
model: 'iPad',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Firefox on iPad */
|
||||||
|
{
|
||||||
|
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.tablet,
|
||||||
vendor: 'Apple',
|
vendor: 'Apple',
|
||||||
model: 'iPad',
|
model: 'iPad',
|
||||||
};
|
};
|
||||||
@ -68,7 +316,7 @@ export default [
|
|||||||
test: [/kftt build/i],
|
test: [/kftt build/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
vendor: 'Amazon',
|
vendor: 'Amazon',
|
||||||
model: 'Kindle Fire HD 7',
|
model: 'Kindle Fire HD 7',
|
||||||
};
|
};
|
||||||
@ -80,7 +328,7 @@ export default [
|
|||||||
test: [/silk/i],
|
test: [/silk/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
vendor: 'Amazon',
|
vendor: 'Amazon',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -88,10 +336,10 @@ export default [
|
|||||||
|
|
||||||
/* Tablet */
|
/* Tablet */
|
||||||
{
|
{
|
||||||
test: [/tablet/i],
|
test: [/tablet(?! pc)/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -106,7 +354,7 @@ export default [
|
|||||||
describe(ua) {
|
describe(ua) {
|
||||||
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
|
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
vendor: 'Apple',
|
vendor: 'Apple',
|
||||||
model,
|
model,
|
||||||
};
|
};
|
||||||
@ -118,18 +366,34 @@ export default [
|
|||||||
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
|
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
vendor: 'Nexus',
|
vendor: 'Nexus',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* Nokia */
|
||||||
|
{
|
||||||
|
test: [/Nokia/i],
|
||||||
|
describe(ua) {
|
||||||
|
const model = Utils.getFirstMatch(/Nokia\s+([0-9]+(\.[0-9]+)?)/i, ua);
|
||||||
|
const platform = {
|
||||||
|
type: PLATFORMS_MAP.mobile,
|
||||||
|
vendor: 'Nokia',
|
||||||
|
};
|
||||||
|
if (model) {
|
||||||
|
platform.model = model;
|
||||||
|
}
|
||||||
|
return platform;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/* Mobile */
|
/* Mobile */
|
||||||
{
|
{
|
||||||
test: [/[^-]mobi/i],
|
test: [/[^-]mobi/i],
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -141,7 +405,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
vendor: 'BlackBerry',
|
vendor: 'BlackBerry',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -154,7 +418,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -166,7 +430,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
vendor: 'Microsoft',
|
vendor: 'Microsoft',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -180,7 +444,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tablet,
|
type: PLATFORMS_MAP.tablet,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -192,7 +456,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.mobile,
|
type: PLATFORMS_MAP.mobile,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -204,7 +468,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.desktop,
|
type: PLATFORMS_MAP.desktop,
|
||||||
vendor: 'Apple',
|
vendor: 'Apple',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -217,7 +481,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.desktop,
|
type: PLATFORMS_MAP.desktop,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -229,7 +493,7 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.desktop,
|
type: PLATFORMS_MAP.desktop,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -241,7 +505,19 @@ export default [
|
|||||||
},
|
},
|
||||||
describe() {
|
describe() {
|
||||||
return {
|
return {
|
||||||
type: TYPES_LABELS.tv,
|
type: PLATFORMS_MAP.tv,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Roku */
|
||||||
|
{
|
||||||
|
test(parser) {
|
||||||
|
return parser.getOSName(true) === 'roku';
|
||||||
|
},
|
||||||
|
describe() {
|
||||||
|
return {
|
||||||
|
type: PLATFORMS_MAP.tv,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -82,12 +82,12 @@ class Parser {
|
|||||||
parseBrowser() {
|
parseBrowser() {
|
||||||
this.parsedResult.browser = {};
|
this.parsedResult.browser = {};
|
||||||
|
|
||||||
const browserDescriptor = browserParsersList.find((_browser) => {
|
const browserDescriptor = Utils.find(browserParsersList, (_browser) => {
|
||||||
if (typeof _browser.test === 'function') {
|
if (typeof _browser.test === 'function') {
|
||||||
return _browser.test(this);
|
return _browser.test(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_browser.test instanceof Array) {
|
if (Array.isArray(_browser.test)) {
|
||||||
return _browser.test.some(condition => this.test(condition));
|
return _browser.test.some(condition => this.test(condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,12 +165,12 @@ class Parser {
|
|||||||
parseOS() {
|
parseOS() {
|
||||||
this.parsedResult.os = {};
|
this.parsedResult.os = {};
|
||||||
|
|
||||||
const os = osParsersList.find((_os) => {
|
const os = Utils.find(osParsersList, (_os) => {
|
||||||
if (typeof _os.test === 'function') {
|
if (typeof _os.test === 'function') {
|
||||||
return _os.test(this);
|
return _os.test(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_os.test instanceof Array) {
|
if (Array.isArray(_os.test)) {
|
||||||
return _os.test.some(condition => this.test(condition));
|
return _os.test.some(condition => this.test(condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,12 +241,12 @@ class Parser {
|
|||||||
parsePlatform() {
|
parsePlatform() {
|
||||||
this.parsedResult.platform = {};
|
this.parsedResult.platform = {};
|
||||||
|
|
||||||
const platform = platformParsersList.find((_platform) => {
|
const platform = Utils.find(platformParsersList, (_platform) => {
|
||||||
if (typeof _platform.test === 'function') {
|
if (typeof _platform.test === 'function') {
|
||||||
return _platform.test(this);
|
return _platform.test(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_platform.test instanceof Array) {
|
if (Array.isArray(_platform.test)) {
|
||||||
return _platform.test.some(condition => this.test(condition));
|
return _platform.test.some(condition => this.test(condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,12 +292,12 @@ class Parser {
|
|||||||
parseEngine() {
|
parseEngine() {
|
||||||
this.parsedResult.engine = {};
|
this.parsedResult.engine = {};
|
||||||
|
|
||||||
const engine = enginesParsersList.find((_engine) => {
|
const engine = Utils.find(enginesParsersList, (_engine) => {
|
||||||
if (typeof _engine.test === 'function') {
|
if (typeof _engine.test === 'function') {
|
||||||
return _engine.test(this);
|
return _engine.test(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_engine.test instanceof Array) {
|
if (Array.isArray(_engine.test)) {
|
||||||
return _engine.test.some(condition => this.test(condition));
|
return _engine.test.some(condition => this.test(condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +313,7 @@ class Parser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse full information about the browser
|
* Parse full information about the browser
|
||||||
|
* @returns {Parser}
|
||||||
*/
|
*/
|
||||||
parse() {
|
parse() {
|
||||||
this.parseBrowser();
|
this.parseBrowser();
|
||||||
@ -328,7 +329,7 @@ class Parser {
|
|||||||
* @return {ParsedResult}
|
* @return {ParsedResult}
|
||||||
*/
|
*/
|
||||||
getResult() {
|
getResult() {
|
||||||
return Object.assign({}, this.parsedResult);
|
return Utils.assign({}, this.parsedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,7 +343,7 @@ class Parser {
|
|||||||
* Returns `undefined` when the browser is no described in the checkTree object.
|
* Returns `undefined` when the browser is no described in the checkTree object.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const browser = new Bowser(UA);
|
* const browser = Bowser.getParser(window.navigator.userAgent);
|
||||||
* if (browser.satisfies({chrome: '>118.01.1322' }))
|
* if (browser.satisfies({chrome: '>118.01.1322' }))
|
||||||
* // or with os
|
* // or with os
|
||||||
* if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
* if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
||||||
@ -370,7 +371,7 @@ class Parser {
|
|||||||
|
|
||||||
if (platformsAndOSCounter > 0) {
|
if (platformsAndOSCounter > 0) {
|
||||||
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
||||||
const OSMatchingDefinition = platformsAndOSNames.find(name => (this.isOS(name)));
|
const OSMatchingDefinition = Utils.find(platformsAndOSNames, name => (this.isOS(name)));
|
||||||
|
|
||||||
if (OSMatchingDefinition) {
|
if (OSMatchingDefinition) {
|
||||||
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
||||||
@ -380,7 +381,10 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const platformMatchingDefinition = platformsAndOSNames.find(name => (this.isPlatform(name)));
|
const platformMatchingDefinition = Utils.find(
|
||||||
|
platformsAndOSNames,
|
||||||
|
name => (this.isPlatform(name)),
|
||||||
|
);
|
||||||
if (platformMatchingDefinition) {
|
if (platformMatchingDefinition) {
|
||||||
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
||||||
|
|
||||||
@ -392,7 +396,7 @@ class Parser {
|
|||||||
|
|
||||||
if (browsersCounter > 0) {
|
if (browsersCounter > 0) {
|
||||||
const browserNames = Object.keys(browsers);
|
const browserNames = Object.keys(browsers);
|
||||||
const matchingDefinition = browserNames.find(name => (this.isBrowser(name, true)));
|
const matchingDefinition = Utils.find(browserNames, name => (this.isBrowser(name, true)));
|
||||||
|
|
||||||
if (matchingDefinition !== void 0) {
|
if (matchingDefinition !== void 0) {
|
||||||
return this.compareVersion(browsers[matchingDefinition]);
|
return this.compareVersion(browsers[matchingDefinition]);
|
||||||
@ -404,20 +408,19 @@ class Parser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the browser name equals the passed string
|
* Check if the browser name equals the passed string
|
||||||
* @param browserName The string to compare with the browser name
|
* @param {string} browserName The string to compare with the browser name
|
||||||
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isBrowser(browserName, includingAlias = false) {
|
isBrowser(browserName, includingAlias = false) {
|
||||||
const defaultBrowserName = this.getBrowserName();
|
const defaultBrowserName = this.getBrowserName().toLowerCase();
|
||||||
const possibleNames = [defaultBrowserName.toLowerCase()];
|
let browserNameLower = browserName.toLowerCase();
|
||||||
const alias = Utils.getBrowserAlias(defaultBrowserName);
|
const alias = Utils.getBrowserTypeByAlias(browserNameLower);
|
||||||
|
|
||||||
if (includingAlias && typeof alias !== 'undefined') {
|
if (includingAlias && alias) {
|
||||||
possibleNames.push(alias.toLowerCase());
|
browserNameLower = alias.toLowerCase();
|
||||||
}
|
}
|
||||||
|
return browserNameLower === defaultBrowserName;
|
||||||
return possibleNames.indexOf(browserName.toLowerCase()) !== -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compareVersion(version) {
|
compareVersion(version) {
|
||||||
@ -456,14 +459,29 @@ class Parser {
|
|||||||
) > -1;
|
) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the OS name equals the passed string
|
||||||
|
* @param {string} osName The string to compare with the OS name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isOS(osName) {
|
isOS(osName) {
|
||||||
return this.getOSName(true) === String(osName).toLowerCase();
|
return this.getOSName(true) === String(osName).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the platform type equals the passed string
|
||||||
|
* @param {string} platformType The string to compare with the platform type
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isPlatform(platformType) {
|
isPlatform(platformType) {
|
||||||
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the engine name equals the passed string
|
||||||
|
* @param {string} engineName The string to compare with the engine name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isEngine(engineName) {
|
isEngine(engineName) {
|
||||||
return this.getEngineName(true) === String(engineName).toLowerCase();
|
return this.getEngineName(true) === String(engineName).toLowerCase();
|
||||||
}
|
}
|
||||||
@ -472,10 +490,12 @@ class Parser {
|
|||||||
* Is anything? Check if the browser is called "anything",
|
* Is anything? Check if the browser is called "anything",
|
||||||
* the OS called "anything" or the platform called "anything"
|
* the OS called "anything" or the platform called "anything"
|
||||||
* @param {String} anything
|
* @param {String} anything
|
||||||
|
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
is(anything) {
|
is(anything, includingAlias = false) {
|
||||||
return this.isBrowser(anything) || this.isOS(anything) || this.isPlatform(anything);
|
return this.isBrowser(anything, includingAlias) || this.isOS(anything)
|
||||||
|
|| this.isPlatform(anything);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
126
src/utils.js
126
src/utils.js
@ -1,4 +1,4 @@
|
|||||||
import { BROWSER_ALIASES_MAP } from './constants.js';
|
import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
|
||||||
|
|
||||||
export default class Utils {
|
export default class Utils {
|
||||||
/**
|
/**
|
||||||
@ -53,6 +53,64 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get macOS version name
|
||||||
|
* 10.5 - Leopard
|
||||||
|
* 10.6 - Snow Leopard
|
||||||
|
* 10.7 - Lion
|
||||||
|
* 10.8 - Mountain Lion
|
||||||
|
* 10.9 - Mavericks
|
||||||
|
* 10.10 - Yosemite
|
||||||
|
* 10.11 - El Capitan
|
||||||
|
* 10.12 - Sierra
|
||||||
|
* 10.13 - High Sierra
|
||||||
|
* 10.14 - Mojave
|
||||||
|
* 10.15 - Catalina
|
||||||
|
* 11 - Big Sur
|
||||||
|
* 12 - Monterey
|
||||||
|
* 13 - Ventura
|
||||||
|
* 14 - Sonoma
|
||||||
|
* 15 - Sequoia
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* getMacOSVersionName("10.14") // 'Mojave'
|
||||||
|
*
|
||||||
|
* @param {string} version
|
||||||
|
* @return {string} versionName
|
||||||
|
*/
|
||||||
|
static getMacOSVersionName(version) {
|
||||||
|
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
|
||||||
|
v.push(0);
|
||||||
|
const major = v[0];
|
||||||
|
const minor = v[1];
|
||||||
|
|
||||||
|
if (major === 10) {
|
||||||
|
switch (minor) {
|
||||||
|
case 5: return 'Leopard';
|
||||||
|
case 6: return 'Snow Leopard';
|
||||||
|
case 7: return 'Lion';
|
||||||
|
case 8: return 'Mountain Lion';
|
||||||
|
case 9: return 'Mavericks';
|
||||||
|
case 10: return 'Yosemite';
|
||||||
|
case 11: return 'El Capitan';
|
||||||
|
case 12: return 'Sierra';
|
||||||
|
case 13: return 'High Sierra';
|
||||||
|
case 14: return 'Mojave';
|
||||||
|
case 15: return 'Catalina';
|
||||||
|
default: return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (major) {
|
||||||
|
case 11: return 'Big Sur';
|
||||||
|
case 12: return 'Monterey';
|
||||||
|
case 13: return 'Ventura';
|
||||||
|
case 14: return 'Sonoma';
|
||||||
|
case 15: return 'Sequoia';
|
||||||
|
default: return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Android version name
|
* Get Android version name
|
||||||
* 1.5 - Cupcake
|
* 1.5 - Cupcake
|
||||||
@ -69,7 +127,7 @@ export default class Utils {
|
|||||||
* 6.x - Marshmallow
|
* 6.x - Marshmallow
|
||||||
* 7.x - Nougat
|
* 7.x - Nougat
|
||||||
* 8.x - Oreo
|
* 8.x - Oreo
|
||||||
* 9.x - ?
|
* 9.x - Pie
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* getAndroidVersionName("7.0") // 'Nougat'
|
* getAndroidVersionName("7.0") // 'Nougat'
|
||||||
@ -94,6 +152,7 @@ export default class Utils {
|
|||||||
if (v[0] === 6) return 'Marshmallow';
|
if (v[0] === 6) return 'Marshmallow';
|
||||||
if (v[0] === 7) return 'Nougat';
|
if (v[0] === 7) return 'Nougat';
|
||||||
if (v[0] === 8) return 'Oreo';
|
if (v[0] === 8) return 'Oreo';
|
||||||
|
if (v[0] === 9) return 'Pie';
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +228,8 @@ export default class Utils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,6 +251,54 @@ export default class Utils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array::find polyfill
|
||||||
|
*
|
||||||
|
* @param {Array} arr
|
||||||
|
* @param {Function} predicate
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
static find(arr, predicate) {
|
||||||
|
let i;
|
||||||
|
let l;
|
||||||
|
if (Array.prototype.find) {
|
||||||
|
return Array.prototype.find.call(arr, predicate);
|
||||||
|
}
|
||||||
|
for (i = 0, l = arr.length; i < l; i += 1) {
|
||||||
|
const value = arr[i];
|
||||||
|
if (predicate(value, i)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object::assign polyfill
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {Object} ...objs
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
static assign(obj, ...assigners) {
|
||||||
|
const result = obj;
|
||||||
|
let i;
|
||||||
|
let l;
|
||||||
|
if (Object.assign) {
|
||||||
|
return Object.assign(obj, ...assigners);
|
||||||
|
}
|
||||||
|
for (i = 0, l = assigners.length; i < l; i += 1) {
|
||||||
|
const assigner = assigners[i];
|
||||||
|
if (typeof assigner === 'object' && assigner !== null) {
|
||||||
|
const keys = Object.keys(assigner);
|
||||||
|
keys.forEach((key) => {
|
||||||
|
result[key] = assigner[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get short version/alias for a browser name
|
* Get short version/alias for a browser name
|
||||||
*
|
*
|
||||||
@ -202,4 +311,17 @@ export default class Utils {
|
|||||||
static getBrowserAlias(browserName) {
|
static getBrowserAlias(browserName) {
|
||||||
return BROWSER_ALIASES_MAP[browserName];
|
return BROWSER_ALIASES_MAP[browserName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get browser name for a short version/alias
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* getBrowserTypeByAlias('edge') // Microsoft Edge
|
||||||
|
*
|
||||||
|
* @param {string} browserAlias
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
static getBrowserTypeByAlias(browserAlias) {
|
||||||
|
return BROWSER_MAP[browserAlias] || '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import Parser from '../../src/parser';
|
import Parser from '../../src/parser';
|
||||||
|
import Bowser from '../../src/bowser';
|
||||||
|
|
||||||
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165';
|
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165';
|
||||||
const parser = new Parser(UA, true);
|
const parser = new Parser(UA, true);
|
||||||
@ -164,6 +165,36 @@ test('Parser.is should pass', (t) => {
|
|||||||
t.is(parser.is('macos'), true);
|
t.is(parser.is('macos'), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.is should pass when not including aliases', (t) => {
|
||||||
|
t.is(edgeParser.is('Microsoft Edge', false), true);
|
||||||
|
t.is(edgeParser.is('microsoft edge', false), true);
|
||||||
|
t.is(edgeParser.is('mIcrosoft eDge', false), true);
|
||||||
|
t.is(edgeParser.is('edge', false), false);
|
||||||
|
t.is(edgeParser.is('Edge', false), false);
|
||||||
|
t.is(edgeParser.is('desktop', false), false);
|
||||||
|
t.is(edgeParser.is('macos', false), false);
|
||||||
|
t.is(edgeParser.is('mobile', false), true);
|
||||||
|
t.is(edgeParser.is('android', false), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.is should pass when including aliases', (t) => {
|
||||||
|
t.is(edgeParser.is('Microsoft Edge', true), true);
|
||||||
|
t.is(edgeParser.is('microsoft edge', true), true);
|
||||||
|
t.is(edgeParser.is('mIcrosoft eDge', true), true);
|
||||||
|
t.is(edgeParser.is('edge', true), true);
|
||||||
|
t.is(edgeParser.is('Edge', true), true);
|
||||||
|
t.is(edgeParser.is('desktop', true), false);
|
||||||
|
t.is(edgeParser.is('macos', true), false);
|
||||||
|
t.is(edgeParser.is('mobile', true), true);
|
||||||
|
t.is(edgeParser.is('android', true), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.is using constants should pass', (t) => {
|
||||||
|
t.is(parser.is(Bowser.BROWSER_MAP.opera), true);
|
||||||
|
t.is(parser.is(Bowser.PLATFORMS_MAP.desktop), true);
|
||||||
|
t.is(parser.is(Bowser.OS_MAP.MacOS), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('Parser.some should pass', (t) => {
|
test('Parser.some should pass', (t) => {
|
||||||
t.is(parser.some(['opera', 'chrome', 'firefox']), true);
|
t.is(parser.some(['opera', 'chrome', 'firefox']), true);
|
||||||
t.is(parser.some(['macos', 'windows']), true);
|
t.is(parser.some(['macos', 'windows']), true);
|
||||||
@ -192,3 +223,8 @@ test('Parser.isBrowser should pass for non-aliased browsers', (t) => {
|
|||||||
t.is(focusParser.isBrowser('Focus', true), true);
|
t.is(focusParser.isBrowser('Focus', true), true);
|
||||||
t.is(focusParser.isBrowser('Focus', false), true);
|
t.is(focusParser.isBrowser('Focus', false), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.isEngine should pass', (t) => {
|
||||||
|
t.is(parser.isEngine('blink'), true);
|
||||||
|
t.is(parser.isEngine('webkit'), false);
|
||||||
|
});
|
||||||
|
|||||||
@ -1,9 +1,18 @@
|
|||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import {
|
import {
|
||||||
getBrowserAlias,
|
|
||||||
getFirstMatch,
|
getFirstMatch,
|
||||||
|
getSecondMatch,
|
||||||
|
matchAndReturnConst,
|
||||||
getWindowsVersionName,
|
getWindowsVersionName,
|
||||||
|
getMacOSVersionName,
|
||||||
|
getAndroidVersionName,
|
||||||
|
getVersionPrecision,
|
||||||
compareVersions,
|
compareVersions,
|
||||||
|
map,
|
||||||
|
find,
|
||||||
|
assign,
|
||||||
|
getBrowserAlias,
|
||||||
|
getBrowserTypeByAlias
|
||||||
} from '../../src/utils';
|
} from '../../src/utils';
|
||||||
|
|
||||||
test('getFirstMatch', (t) => {
|
test('getFirstMatch', (t) => {
|
||||||
@ -11,11 +20,45 @@ test('getFirstMatch', (t) => {
|
|||||||
t.is(matchedVersion, '11.11.11');
|
t.is(matchedVersion, '11.11.11');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getSecondMatch', (t) => {
|
||||||
|
const matchedVersion = getSecondMatch(/version\/(\S+).*version\/(\S+)/i, 'Chrome Version/11.11.11 Chrome Version/22.22.22');
|
||||||
|
t.is(matchedVersion, '22.22.22');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('matchAndReturnConst', (t) => {
|
||||||
|
const _const = matchAndReturnConst(/version/i, 'version', "_const");
|
||||||
|
t.is(_const, '_const');
|
||||||
|
});
|
||||||
|
|
||||||
test('getWindowsVersionName', (t) => {
|
test('getWindowsVersionName', (t) => {
|
||||||
t.is(getWindowsVersionName('NT 5.0'), '2000');
|
t.is(getWindowsVersionName('NT 5.0'), '2000');
|
||||||
t.is(getWindowsVersionName('XXX'), void 0);
|
t.is(getWindowsVersionName('XXX'), void 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getMacOSVersionName', (t) => {
|
||||||
|
t.is(getMacOSVersionName('10.14.5'), 'Mojave');
|
||||||
|
t.is(getMacOSVersionName('10.15'), 'Catalina');
|
||||||
|
t.is(getMacOSVersionName('11.0'), 'Big Sur');
|
||||||
|
t.is(getMacOSVersionName('12.3.1'), 'Monterey');
|
||||||
|
t.is(getMacOSVersionName('13.2.1'), 'Ventura');
|
||||||
|
t.is(getMacOSVersionName('14.0'), 'Sonoma');
|
||||||
|
t.is(getMacOSVersionName('15.1'), 'Sequoia');
|
||||||
|
t.is(getMacOSVersionName('10.999999'), void 0);
|
||||||
|
t.is(getMacOSVersionName('XXX'), void 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getAndroidVersionName', (t) => {
|
||||||
|
t.is(getAndroidVersionName('1.0'), void 0);
|
||||||
|
t.is(getAndroidVersionName('8.0'), 'Oreo');
|
||||||
|
t.is(getAndroidVersionName('9'), 'Pie');
|
||||||
|
t.is(getAndroidVersionName('XXX'), void 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getVersionPrecision', (t) => {
|
||||||
|
const precision = getVersionPrecision("10.14.5");
|
||||||
|
t.is(precision, 3);
|
||||||
|
});
|
||||||
|
|
||||||
test('compareVersions', (t) => {
|
test('compareVersions', (t) => {
|
||||||
const comparisionsTasks = [
|
const comparisionsTasks = [
|
||||||
['9.0', '10', -1],
|
['9.0', '10', -1],
|
||||||
@ -52,7 +95,51 @@ test('compareVersions', (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('map', (t) => {
|
||||||
|
const result = map([1,2], (value) => value+2);
|
||||||
|
t.is(result[0], 3);
|
||||||
|
t.is(result[1], 4);
|
||||||
|
const original = Array.prototype.map;
|
||||||
|
delete Array.prototype.map;
|
||||||
|
const polyfillResult = map([1,2], (value) => value+2);
|
||||||
|
Array.prototype.map = original;
|
||||||
|
t.is(polyfillResult[0], 3);
|
||||||
|
t.is(polyfillResult[1], 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('find', (t) => {
|
||||||
|
const result = find([1,2], (value) => value==2);
|
||||||
|
t.is(result, 2);
|
||||||
|
const original = Array.prototype.find;
|
||||||
|
delete Array.prototype.find;
|
||||||
|
const polyfillResultFound = find([1,2], (value) => value==2);
|
||||||
|
const polyfillResultNotFound = find([1,2], (value) => value==3);
|
||||||
|
Array.prototype.find = original;
|
||||||
|
t.is(polyfillResultFound, 2);
|
||||||
|
t.is(polyfillResultNotFound, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('assign', (t) => {
|
||||||
|
const result = assign({}, { a: 1 }, { b: 1 }, { b: 2, c: 3 });
|
||||||
|
t.is(result['a'], 1);
|
||||||
|
t.is(result['b'], 2);
|
||||||
|
t.is(result['c'], 3);
|
||||||
|
const original = Object.assign;
|
||||||
|
delete Object.assign;
|
||||||
|
const polyfillResult = assign({}, { a: 1 }, { b: 1 }, null, { b: 2, c: 3 });
|
||||||
|
Object.assign = original;
|
||||||
|
t.is(polyfillResult['a'], 1);
|
||||||
|
t.is(polyfillResult['b'], 2);
|
||||||
|
t.is(polyfillResult['c'], 3);
|
||||||
|
});
|
||||||
|
|
||||||
test('getBrowserAlias', (t) => {
|
test('getBrowserAlias', (t) => {
|
||||||
t.is(getBrowserAlias('Microsoft Edge'), 'edge');
|
t.is(getBrowserAlias('Microsoft Edge'), 'edge');
|
||||||
t.is(getBrowserAlias('Unexisting Browser'), void 0);
|
t.is(getBrowserAlias('Unexisting Browser'), void 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getBrowserTypeByAlias', (t) => {
|
||||||
|
t.is(getBrowserTypeByAlias('edge'), 'Microsoft Edge');
|
||||||
|
t.is(getBrowserTypeByAlias(void 0), '');
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||||
|
const CompressionPlugin = require('compression-webpack-plugin');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
new CompressionPlugin(),
|
||||||
|
],
|
||||||
mode: 'production', // "production" | "development" | "none"
|
mode: 'production', // "production" | "development" | "none"
|
||||||
// Chosen mode tells webpack to use its built-in optimizations accordingly.
|
// Chosen mode tells webpack to use its built-in optimizations accordingly.
|
||||||
entry: {
|
entry: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user