2.0.0 • Published 10 months ago

stevenblack v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

stevenblack

This is a tiny package that checks if a domain is blacklisted in StevenBlack hosts file

This package will always pull the latest hosts file from the main repo https://github.com/StevenBlack/hosts during installation.

I created this package for my needs which is to block NSFW links from my projects.

Installation

npm install stevenblack

Usage

The default export of this package is a function that returns a Promise with a boolean value.

It reads the downloaded hosts file line by line and compare it against the given string.

It throws an error if for some reason the hosts file does not exists.

const isBlacklisted = require('stevenblack')

async function main() {
  if (await isBlacklisted('nsfw-domain.com')) {
    throw new Error('Domain is blacklisted')
  }

  console.log('All good!')
}

main()
2.0.0

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago