Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

๐Ÿฒ A dead simple Go module that counts Adblock filter rules. Adaptation of my original npm/TypeScript package.๐Ÿฆ˜
https://github.com/igorskyflyer/go-adblock-filter-counter

adblock adblock-filter back-end count counter filter go igorskyflyer module typescript utility

Last synced: 2 days ago
JSON representation

๐Ÿฒ A dead simple Go module that counts Adblock filter rules. Adaptation of my original npm/TypeScript package.๐Ÿฆ˜

Awesome Lists containing this project

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](https://github.com/igorskyflyer/go-adblock-filter-counter/releases) page for a changelog.


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

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

and import it like

```go
...

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

...
```


## ๐Ÿคน๐Ÿผ Examples

### `CountRules(source string) int`

```go
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)`

```go
filePath string = "./data/AdVoid.Core.txt"

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

```