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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@binance/ua-parser-url

v0.0.1

Published

Mini UAParser implementation for Binance web projects

Readme

@binance/ua-parser-url

A lightweight User-Agent parser for Binance web projects, designed to replace ua-parser-js with a smaller, more focused implementation.

Features

  • Lightweight: Only ~5KB minified, compared to ~40KB for ua-parser-js
  • Focused: Only implements the functionality actually used in Binance projects
  • TypeScript: Full TypeScript support with proper type definitions
  • Compatible: API compatible with ua-parser-js for easy migration

Installation

npm install @binance/ua-parser-url

Usage

Basic Usage

import { UAParser } from '@binance/ua-parser-url'

// Create parser with current user agent
const parser = new UAParser()

// Get complete result
const result = parser.getResult()
console.log(result)
// {
//   ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...",
//   browser: { name: "Chrome", version: "126.0.0.0", major: "126" },
//   engine: { name: "Blink", version: "126.0.0.0" },
//   os: { name: "macOS", version: "10.15.7" },
//   device: { model: "Macintosh", type: "desktop", vendor: "Apple" },
//   cpu: { architecture: undefined }
// }

// Create parser with custom user agent
const customParser = new UAParser('Custom User Agent String')

Device Detection

import { UAParser } from '@binance/ua-parser-url'

const parser = new UAParser()

// Get device information
const device = parser.getDevice()
console.log(device)
// { model: "iPhone", type: "mobile", vendor: "Apple" }

Browser Detection

import { UAParser } from '@binance/ua-parser-url'

const parser = new UAParser()
const result = parser.getResult()

console.log(result.browser)
// { name: "Chrome", version: "126.0.0.0", major: "126" }

OS Detection

import { UAParser } from '@binance/ua-parser-url'

const parser = new UAParser()
const result = parser.getResult()

console.log(result.os)
// { name: "macOS", version: "10.15.7" }

Supported Browsers

  • Chrome
  • Chrome WebView
  • Safari
  • Mobile Safari
  • Firefox
  • Edge
  • WebKit (fallback)

Supported Operating Systems

  • macOS
  • iOS
  • Windows
  • Android
  • Linux

Supported Devices

  • iPhone (mobile)
  • iPad (tablet)
  • Android devices (mobile)
  • Desktop devices

API Reference

UAParser

Constructor

new UAParser(userAgent?: string)
  • userAgent (optional): Custom user agent string. If not provided, uses navigator.userAgent

Methods

getResult(): IUAParser

Returns the complete parsing result.

getDevice(): IUAParser['device']

Returns device information (model, type, vendor).

setUA(userAgent: string): UAParser

Sets a custom user agent string and returns the parser instance for chaining.

getUA(): string

Returns the current user agent string.

Types

interface IUAParser {
  ua: string
  browser: {
    name: string | undefined
    version: string | undefined
    major: string | undefined
  }
  engine: {
    name: string | undefined
    version: string | undefined
  }
  os: {
    name: string | undefined
    version: string | undefined
  }
  device: {
    model: string | undefined
    type: string | undefined
    vendor: string | undefined
  }
  cpu: {
    architecture: string | undefined
  }
}

Migration from ua-parser-js

This library is designed to be a drop-in replacement for ua-parser-js in most cases:

// Before (ua-parser-js)
import { UAParser } from 'ua-parser-js'
const parser = new UAParser()
const result = parser.getResult()

// After (@binance/ua-parser-url)
import { UAParser } from '@binance/ua-parser-url'
const parser = new UAParser()
const result = parser.getResult()

Differences from ua-parser-js

  1. Smaller size: ~5KB vs ~40KB
  2. Focused functionality: Only implements features used in Binance projects
  3. Simplified API: Some advanced features are not implemented
  4. Better TypeScript support: Native TypeScript implementation

Development

Building

npm run build

Testing

npm test

Linting

npm run lint

License

MIT