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

bun-whois-parser

v1.1.6

Published

A Bun whois parser

Downloads

6

Readme

Bun whois parser

(WIP) Not tested to ALL tlds

You can see the regex-patterns in patterns.js

(Big thanks to @moneals for writing most of the regex <3)

How to use it?

I recommend to use a tool to lookup whois, just like whois-light. Then you can simply pass the raw data into the parser just like this:

const { lookup } = require("whois-light")
const parser = require('bun-whois-parser')

const url = 'https://caamillo.it' // url to lookup
try {
    const raw = await lookup(url) // lookup using whois-light
    const parsed = await parser(raw, url) // url not required
    console.log(parsed) // Your parsed whois!
} catch(err) {
    // Handle lookup error
    console.error(err)
}

Parameters

| Key | Description | Default | |-----------|----------------------------------------------------------|-----------| | data | whois raw data | undefined | | url? | fetched url/domain | undefined | | toISO? | parse all dates into ISO format | true | | optimize? | dangerous, read more in the "Optimize Parameter" section | false |

Response

Basically a json with the following description:

| Key | Description | |--------------------|--------------------------| | tld | tld name | | available | is the domain available? | | domainName | domain name | | registrar | whois registrar | | updatedDate | whost updated date | | creationDate | whois creation date | | expirationDate | whois expiration date | | status | whois status |

How does it work?

  1. Makes an object of all the hard coded TLD regex pattern (you can see them inside patterns.js).
// Example of regex-pattern, useful to make your regex
{
    tld: 'tld-name',
    regex: {
        domainName: 'domain-name-regex',
        registrar: 'registrar-regex',
        updatedDate: 'updated-date-regex',
        creationDate: 'creation-date-regex',
        expirationDate: 'expiration-date-regex',
        status: 'status-regex'
    },
    etc: {
        notFound: 'regex-to-see-if-available',
        dateFormat: 'the-format-to-parse-date',
        rateLimited: 'custom-whois-message-when-many-requests'
    }
}
// ALL the fields and sub-fields (regex || domainName) are optional except for `tld` attribute
  1. If a field or a sub-field is not given, they will be overrided by default-pattern patterns[0], so it's top-to-down.
  2. Now checks the tlds.json file and if a tld is not given, then it makes an empty pattern object (with default-pattern active)
  3. Your parse it's ready sir!

Optimize Parameter

Use the algorithm avoiding adding all the tlds that are not found in patterns.js. This parameter is setted to off by default, but you may would use it if you know what tlds you will work with.

Features

  • Fastest whois-parser (~0,02s with optimize parameter, ~0,04s without),
  • Offline and sync,
  • Domain name auto detection,
  • Domain name wrapper from URL

TODOs

  • [x] Parse dates using dateFormat attribute
  • [ ] Better tlds.json
  • [ ] Use rateLimited
  • [ ] Make tests to run whois in various tlds to search which one can't be parsed

Please consider to collaborate on that. The more regex-patterns we write, the better it is.