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

htmlhash

v0.0.1-alpha.1

Published

Calculate the hash value of HTML files and compare them for similarity. Hash is based on the HTML structure and technologies, not the content.

Downloads

8

Readme

htmlhash

Calculate the hash value of HTML files and compare them for similarity. Hash is based on the HTML structure and technologies, not the content.

> This is fully experimental and still subject to have breaking changes until stable release.

Prerequisites

Make sure you have the following dependencies installed:

  • Node.js
  • bun (npm install -g bun)

Installation

  1. Clone the repository to your local machine.
  2. Open a terminal and navigate to the project directory.
  3. Run the command bun to install the required dependencies.

Usage

import * as hh from 'htmlhash'

const html1 = '<html><body><h1>Hello, world!</h1></body></html>'
const hash1 = hh.hash(html1)
console.log(hash1) // Z0O01Z0U08Z0Z0Z0h02Z0Z0Z0Z0h02Z0Z0Z0S04Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0J0

const html2 = '<html><body><h2>Hello, world!</h2></body></html>'
const hash2 = hh.hash(html2)
console.log(hash2) // Z0O01Z0U08Z0Z0Z0h02Z0Z0j04Z0W02v08Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z0Z00

const score = hh.similarity(hh.toBinary(hash1), hh.toBinary(hash2))
console.log(score) // 0.9998385012919897

console.log('dif', hh.differences(hash1, hash2)) // [ "tag-h2", "tag-h1" ]

Predicates groups

All predicates are considered equal. Also, for clarity they've been grouped by the following prefixes:

  • tag: the tag name
  • meta: the meta related attributes
  • attr: the attribute name
  • attr-id: the id
  • attr-class: the classes
  • attr-itemprop: the itemprop attributes
  • js: the javascript code snippets
  • css: the css code snippets
  • tech: the detected technologies (originally based on Wappalyzer)

Think of them as a way to organize the predicates in a trackable way (and avoid duplicates).

Have ideas for more predicates? Please create an issue on the GitHub repository.

Remaining before stable

  1. Review all technologies (a lot of them are missing or should be simplified)
  2. Set up tests suite
  3. Add more verticals
  4. Add more predicates

License

This project is licensed under the MIT license. Please see the LICENSE file for more information.

Disclaimer

This tool is provided as-is without any warranty. Use it at your own risk.

For any issues or suggestions, please create an issue on the GitHub repository.