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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@igorskyflyer/adblock-filter-counter

v1.1.0

Published

🐲 A lightweight npm module for counting ad-block filter rules, ultra-simple, fast, and perfect for list maintainers, filter testers, and privacy tool developers.🦘

Readme

📃 Table of Contents

🤖 Features

  • ⚡ Counts ad-block rules from strings or files instantly
  • 🧠 Ignores comments and metadata for clean totals
  • 🧼 Syntax-agnostic - no parser, no dependencies
  • 📁 Reads UTF-8 files with a single call
  • 🧪 Type-safe - returns exact rule count as number
  • 🚫 Throws clear errors for invalid input or missing files
  • 🧵 Works with EasyList, AdVoid, and custom filters
  • 🧩 Ideal for audits, benchmarks, and list hygiene
  • 🐇 Fast - handles tens of thousands of rules in milliseconds
  • 🔒 No network, no fetch, no async - pure local logic

🕵🏼 Usage

Install it by executing any of the following, depending on your preferred package manager:

pnpm add @igorskyflyer/adblock-filter-counter
yarn add @igorskyflyer/adblock-filter-counter
npm i @igorskyflyer/adblock-filter-counter

🤹🏼 API

countRules(rules: string): number

Counts ad-block filter rules found in the provided string.

rules - The ad-block filter string to count rules in.

Throws if the input is not a string.
Returns the number of filter rules.

countFileRules(path: PathLike): number

Counts ad-block filter rules found in the provided file.

path - The path to the file that contains the filter rules to count.

Throws if the file cannot be read or is not a valid UTF-8 string.
Returns the number of filter rules.

🗒️ Examples

index.ts

import { countFileRules, countRules } from '@igorskyflyer/adblock-filter-counter'

const total: number = countFileRules('./AdVoid.Full.txt')
console.log(`AdVoid.Full contains ${total} rules.`) // AdVoid.Full contains 7,916 rules.

const raw: string = `
||ads.example.com^
||tracker.net^
! this is a comment
##.ad-banner
`
const count: number = countRules(raw)
console.log(`Inline list contains ${count} rules.`) // Inline list contains 3 rules.

📝 Changelog

📑 Read about the latest changes in the CHANGELOG.

🪪 License

Licensed under the MIT license.

💖 Support

🧬 Related

@igorskyflyer/aria

🧬 Meet Aria, an efficient ad-block filter list compiler, with many features that make your maintenance of ad-block filter lists a breeze! 🦖

@igorskyflyer/adblock-header-extract

✂️ An npm module that provides ways to extract header and metadata from an ad-block filter file. 📃

@igorskyflyer/strip-html

🥞 Removes HTML code from the given string. Can even extract text-only from the given an HTML string. ✨

@igorskyflyer/astro-saferesource

🎐 Adds CSP-compliant inline scripts and styles to Astro! 🎠

@igorskyflyer/astro-easynav-button

🧭 Add an easy-to-use navigational button (jump to top/bottom) to your Astro site. 🔼

👨🏻‍💻 Author

Created by Igor Dimitrijević (@igorskyflyer).