npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uas-parser

v0.2.3

Published

User agent string parser (using data from user-agent-string.info)

Downloads

31

Readme

uas-parser

Build Status

A user agent string parser for Node.js. Returns detailed user agent information from the user-agent-string.info project.

The internal data used for parsing is automatically updated on weekly basis from user-agent-string.info's latest downloads.

Usage

parse(userAgent)

Parse the given user agent string. Returns an object containing browser details and operating system information.

Examples

var uaParser = require('uas-parser');

uaParser.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17');
// { type: 'Browser',
//   uaFamily: 'Safari',
//   uaName: 'Safari 6.0.2',
//   uaUrl: 'http://en.wikipedia.org/wiki/Safari_%28web_browser%29',
//   uaCompany: 'Apple Inc.',
//   uaCompanyUrl: 'http://www.apple.com/',
//   uaIcon: 'http://user-agent-string.info/pub/img/ua/safari.png',
//   uaInfoUrl: 'http://user-agent-string.info/list-of-ua/browser-detail?browser=Safari',
//   osFamily: 'OS X',
//   osName: 'OS X 10.7 Lion',
//   osUrl: 'http://www.apple.com/osx/',
//   osCompany: 'Apple Computer, Inc.',
//   osCompanyUrl: 'http://www.apple.com/',
//   osIcon: 'http://user-agent-string.info/pub/img/os/macosx.png',
//   deviceType: 'Personal computer',
//   deviceIcon: 'http://user-agent-string.info/pub/img/device/desktop.png',
//   deviceInfoUrl: 'http://user-agent-string.info/list-of-ua/device-detail?device=Personal computer' }

uaParser.parse('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)');
// { type: 'Robot',
//   uaFamily: 'bingbot',
//   uaName: 'bingbot/2.0',
//   uaUrl: 'http://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0',
//   uaCompany: 'Microsoft Corporation',
//   uaCompanyUrl: 'http://www.microsoft.com/',
//   uaIcon: 'http://user-agent-string.info/pub/img/ua/bot_msnbot.png',
//   uaInfoUrl: 'http://user-agent-string.info/list-of-ua/bot-detail?bot=bingbot',
//   osFamily: 'unknown',
//   osName: 'unknown',
//   osUrl: 'unknown',
//   osCompany: 'unknown',
//   osCompanyUrl: 'unknown',
//   osIcon: 'http://user-agent-string.info/pub/img/os/unknown.png',
//   deviceType: 'Other',
//   deviceIcon: 'http://user-agent-string.info/pub/img/device/other.png',
//   deviceInfoUrl: 'http://user-agent-string.info/list-of-ua/device-detail?device=Other' }

uaParser.parse('EventMachine HttpClient');
// { type: 'Library',
//   uaFamily: 'EventMachine',
//   uaName: 'EventMachine',
//   uaUrl: 'http://rubyeventmachine.com/',
//   uaCompany: '',
//   uaCompanyUrl: '',
//   uaIcon: 'http://user-agent-string.info/pub/img/ua/DLLicon.png',
//   uaInfoUrl: 'http://user-agent-string.info/list-of-ua/browser-detail?browser=EventMachine',
//   osFamily: 'unknown',
//   osName: 'unknown',
//   osUrl: 'unknown',
//   osCompany: 'unknown',
//   osCompanyUrl: 'unknown',
//   osIcon: 'http://user-agent-string.info/pub/img/os/unknown.png',
//   deviceType: 'Other',
//   deviceIcon: 'http://user-agent-string.info/pub/img/device/other.png',
//   deviceInfoUrl: 'http://user-agent-string.info/list-of-ua/device-detail?device=Other' }

lookup(userAgent)

Provides the same functionality as parse(userAgent), but caches the results for the given user agent string in memory. This can provide faster lookups when repeatedly parsing identical user agent strings.

The last 5,000 user agent strings seen will be cached. Cached results will remain valid for up to 1 week.

Other User Agent Parsers

  • useragent: Derived from browserscope.org's user agent parser. An excellent user agent parser for web browsers, but I found user-agent-string.info's data better at categorizing and dealing with robots, software libraries, and other more esoteric user agents (at least for my use case).

Credits

All user agent data is from user-agent-string.info. Data is licensed under a Creative Commons Attribution 3.0 Unported License.