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

random-ua

v0.0.6

Published

Randomly generates User-Agent strings based on actual usage statistics from Wikimedia.

Downloads

1,589

Readme

random-ua.js - A random User-Agent Generator

Randomly generates User-Agent strings based on actual browser market share and usage statistics.

Caveats

The version numbers generated are sane, however, revisions are totally random and unlikely to exist in the wild.

I decided not to include language selection found in the PHP version and instead include all the languages in the ISO639-2 standard because it's atypical for sites to determine client locale based on the user-agent.

Usage

var random_ua = require('random-ua');

console.log(random_ua.generate());
//Easy like Sunday morning

//You can easily use random_ua to generate a random User-Agent for an HTTP request:

var http = require('http');

http.get({
        host:'whatsmyuseragent.com',
        path:'/',
        headers:{
            'User-Agent':random_ua.generate()
        }
    },
    function (res) {
        if (res.statusCode === 200) {
            var body = [];
            res.setEncoding('utf8');
            res.on('data', function (chunk) {
                body.push(chunk);
            });
            res.on('end', function () {
                body = body.join('');
                console.log(body);
            });
        } else {
            console.log('Error retrieving page: ' + res.statusCode);
        }
    }
);

Options

Please send your suggestions for improvements or updates.

Based Upon

This script is roughly based upon Luka Pusic's PHP script: http://360percents.com/posts/php-random-user-agent-generator/

A refactored version in PHP is available on GitHub at: https://raw.github.com/mwhite/random-uagent/

License

MIT License