Package Exports
- device-detector-js
- device-detector-js/dist/parsers/bot
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (device-detector-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
device-detector-js
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.
This is a Node.js port of Matomo device-detector.
Getting Started
Installation
To use device-detector-js in your project, run:
npm install device-detector-jsUsage
Example - converting a svg to png:
const DeviceDetector = require("device-detector-js");
const deviceDetector = new DeviceDetector();
const userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36";
const device = deviceDetector.parse(userAgent);
console.log(device);Output:
{
"client": {
"type": "browser",
"name": "Chrome",
"version": "69.0",
"engine": "Blink",
"engineVersion": ""
},
"os": {
"name": "Mac",
"version": "10.13",
"platform": ""
},
"device": {
"type": "desktop",
"brand": "Apple",
"model": ""
},
"bot": null
}Built with
- Matomo device detector - A powerful device detection library.
- node.js - Cross-platform JavaScript run-time environment for executing JavaScript code server-side.
- TypeScript - Typed superset of JavaScript that compiles to plain JavaScript.
- Jest - Delightful JavaScript Testing.
Contributing
When contributing to this project, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Update the README.md with details of changes to the library.
Execute npm run test and update the tests if needed.
Authors
- Etienne Martin - Initial work - etiennemartin.ca
License
This project is licensed under the MIT License - see the LICENSE file for details.