abcounter

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 3 Imported by: 0

README

🐝 go := "Adblock filter counter"

🐲 A dead simple Go module that counts Adblock filter rules.🦘

Note: it only operates on a string-level, it doesn't check the validity of the provided filter rules.



Documentation: https://godocs.io/github.com/igorskyflyer/go-adblock-filter-counter

See the releases page for a changelog.


This library requires Go 1.20 or newer; add it to your go.mod with:

go get github.com/igorskyflyer/go-adblock-filter-counter@latest

and import it like

...

import (
	abcounter "github.com/igorskyflyer/go-adblock-filter-counter"
)

...

🤹🏼 Examples

CountRules(source string) int
source string = `
	[Adblock Plus 2.0]
	||hello.world^
	||hello.world^
	||hello.world^
	! Comment
	||another.test^
	`

abcounter.CountRules(source) // returns 4


CountFileRules(filename string) (int, error)
filePath string = "./data/AdVoid.Core.txt"

abcounter.CountFileRules(filePath) // returns (2495, nil)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountFileRules

func CountFileRules(filename string) (int, error)

Counts Adblock filter rules found in the provided file.

It returns the number of filter rules or -1 in case of an error.

func CountRules

func CountRules(source string) int

Counts Adblock filter rules found in the provided string.

It returns the number of filter rules.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL