{"id":19621321,"url":"https://github.com/commenthol/ua-parser2","last_synced_at":"2025-04-28T03:32:19.730Z","repository":{"id":57384284,"uuid":"22674429","full_name":"commenthol/ua-parser2","owner":"commenthol","description":"Improved user-agent parser","archived":false,"fork":false,"pushed_at":"2021-01-28T19:21:22.000Z","size":6883,"stargazers_count":13,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T23:40:35.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commenthol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-06T07:57:02.000Z","updated_at":"2023-05-23T11:38:49.000Z","dependencies_parsed_at":"2022-09-26T16:50:28.710Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/ua-parser2","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fua-parser2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fua-parser2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fua-parser2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fua-parser2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/ua-parser2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246236,"owners_count":21558761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:22:21.342Z","updated_at":"2025-04-28T03:32:15.821Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ua-parser2\n==========\n\n[![NPM version](https://badge.fury.io/js/ua-parser2.svg)](https://www.npmjs.com/package/ua-parser2/)\n[![Build Status](https://secure.travis-ci.org/commenthol/ua-parser2.svg?branch=master)](https://travis-ci.org/commenthol/ua-parser2)\n\nThis is an improved fork from [ua-parser][ua-parser] which contains the following changes documented in the [Changelog][chan].\n\nThe crux of the original parser --the data collected by [Steve Souders][stev] over the years-- has been extracted into a separate [YAML file][yaml] so as to be reusable _as is_ by implementations in other programming languages.\n\nThe main differences to [ua-parser][ua-parser] are:\n\n* Parsing Engines - Detection of MSIE compatibility modes\n* Grouping of regexes - Speeds up User-Agent detection by \u003e 200%\n* Adding `type` attribute - tag a user-agent category with a specific type such as. 'bot', 'mail', 'feedreader', 'app', ...\n* Bundled tools for contribution.\n* Running your own `regexes.yaml` file\n* Backwards Compatibility using the \"old\" UAParser result object is broken.\n\n\n## Contributing Changes to regexes.yaml\n\nPlease read the [contributors' guide][guid]\n\n\n## Specification\n\nA [Specification][spec], e.g. for porting into other computer languages of the parsing rules for the `regexes.yaml` file is available.\n\n\n## Usage\n\n[API Documentation][api]\n\n```javascript\nvar uaParser = require('ua-parser2')(/* [optional] path to your regexes.yaml file */);\n\nvar res,\n    userAgent = \"Mozilla/5.0 (Linux; Android 4.3.1; LG-E980 Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36\";\n\nres = uaParser.parse(userAgent);\n\nconsole.log(res);\n```\n\nThere is a sample in `./js/test/sample.js` which can be executed from the commandline.\n\n```bash\nnode js/test/sample.js \"Mozilla/5.0 (Linux; Android 4.3.1; LG-E980 Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36\"\n#\u003e {\n  \"ua\": {\n    \"family\": \"Chrome Mobile\",\n    \"major\": \"31\",\n    \"minor\": \"0\",\n    \"patch\": \"1650\"\n  },\n  \"engine\": {\n    \"family\": \"Blink\",\n    \"major\": \"31\",\n    \"minor\": \"0\",\n    \"patch\": \"1650\"\n  },\n  \"os\": {\n    \"family\": \"Android\",\n    \"major\": \"4\",\n    \"minor\": \"3\",\n    \"patch\": \"1\",\n    \"patchMinor\": null\n  },\n  \"device\": {\n    \"family\": \"LG-E980\",\n    \"brand\": \"LG\",\n    \"model\": \"E980\",\n    \"type\": \"smartphone\"\n  },\n  \"string\": \"Mozilla/5.0 (Linux; Android 4.3.1; LG-E980 Build/JLS36I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36\"\n}\n\nnode js/test/sample.js \"AdsBot-Google-Mobile ( http://www.google.com/mobile/adsbot.html) Mozilla (iPhone; U; CPU iPhone OS 3 0 like Mac OS X) AppleWebKit (KHTML, like Gecko)\"\n#\u003e {\n  \"ua\": {\n    \"family\": \"AdsBot-Google-Mobile\",\n    ...\n    \"type\": \"bot\"\n  },\n  \"engine\": {\n    \"family\": \"Webkit\",\n    ...\n    \"type\": \"Apple\"\n  },\n  \"os\": {\n    \"family\": \"Other\",\n    ...\n  },\n  \"device\": {\n    \"family\": \"iPhone\",\n    \"brand\": \"Apple\",\n    \"model\": \"iPhone\",\n    \"type\": \"smartphone\"    \n  },\n  \"string\": \"AdsBot-Google-Mobile ( http://www.google.com/mobile/adsbot.html) Mozilla (iPhone; U; CPU iPhone OS 3 0 like Mac OS X) AppleWebKit (KHTML, like Gecko)\"\n}\n```\n\nNote if you're only interested in one of the `ua`, `device` or `os` objects, you will getter better performance by using the more specific methods (`uaParser.parseUA`, `uaParser.parseOS` and `uaParser.parseDevice` respectively), e.g.:\n\n```js\nvar p = require('ua-parser2')();\n\nvar userAgent = \"Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/9B179 Safari/7534.48.3\";\n\nconsole.log(p.parseUA(userAgent).toString());\n//\u003e \"Chrome Mobile iOS 27.0.1453\"\nconsole.log(p.parseEngine(userAgent).toString());\n//\u003e \"AppleWebkit 534.46\"\nconsole.log(p.parseOS(userAgent).toString());\n//\u003e \"iOS 5.1\"\nconsole.log(p.parseDevice(userAgent).toString());\n//\u003e \"Apple iPhone\"\n```\n\n\n## Benchmarks\n\nIn folder `benchmarks` you'll find a benchmark test which compares [useragent][], [node-uap][] with `ua-parser2`.\n\nResults on my laptop:\n\n- node-uap@0.0.3\n- useragent@2.2.1\n- ua-parser2@0.3.2\n\n```\nStarting the benchmark, parsing 63 useragent strings per run\n\nExecuted benchmark against node module: \"useragent\"\nCount (3), Cycles (2), Elapsed (5.782), Hz (40.84696387495286)\n\nExecuted benchmark against node module: \"node-uap\"\nCount (3), Cycles (2), Elapsed (5.628), Hz (41.23226067803832)\n\nExecuted benchmark against node module: \"ua-parser2\"\nCount (7), Cycles (4), Elapsed (5.568), Hz (108.4435776239968)\n\nModule: \"ua-parser2\" is the user agent fastest parser.\n```\n\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license.\nFor contribution to the `regexes.yaml` you are implicitly allowing your code to be distributed under the Apache License license\nYou are also implicitly verifying that all code is your original work.\n\n\n## License\n\nThe data contained in `regexes.yaml` is Copyright 2014 commenthol, 2009 Google Inc. and available under the [Apache License, Version 2.0][apac].\n\nThe JS port is Copyright 2014 commenthol, 2010 Tobie Langel and is available under [your choice of MIT or Apache Version 2.0 license][lice].\n\n[node]: http://nodejs.org\n[stev]: http://stevesouders.com/\n[apac]: http://www.apache.org/licenses/LICENSE-2.0\n[lice]: LICENSE\n[spec]: doc/specification.md\n[api]:  js/doc/uaparser.md\n[guid]: CONTRIBUTING.md\n[chan]: CHANGELOG.md\n[yaml]: https://raw.github.com/commenthol/ua-parser2/master/regexes.yaml\n[ua-parser]: http://github.com/tobie/ua-parser\n[useragent]: https://github.com/3rd-Eden/useragent\n[node-uap]: https://github.com/fedot/node-uap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fua-parser2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fua-parser2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fua-parser2/lists"}