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

@antistatique/blaspjs

v0.0.2

Published

TypeScript port of Blaspsoft Blasp (v4) — profanity detection, masking, drivers (regex, pattern, phonetic, pipeline), multi-language dictionaries.

Readme

@antistatique/blaspjs

TypeScript / JavaScript library that ports the language-agnostic core of Blaspsoft Blasp v4: driver-based profanity detection, severity scoring, masking, and multi-language dictionaries (English, Spanish, German, French). It is intended for Node.js and bundlers (ESM); the build targets modern browsers as well.

Blasp itself is a Laravel package; this project does not ship Laravel integration. Use it in Express, Nest, Remix, serverless handlers, or any TS/JS runtime.

Installation

npm install @antistatique/blaspjs
# or
bun add @antistatique/blaspjs

Peer dependency: TypeScript ^5.0 (optional if you consume only JavaScript).

Quick start

import { Blasp, Severity } from '@antistatique/blaspjs';

const blasp = new Blasp();

const result = blasp.check('This is a fucking sentence');

result.isOffensive(); // true
result.clean(); // masked text (e.g. asterisks)
result.original(); // unchanged input
result.score(); // 0–100
result.count(); // number of matches
result.uniqueWords(); // unique dictionary bases
result.severity(); // highest SeverityLevel in matches, or null

A default instance is also exported as blasp (same defaults as new Blasp()).

Fluent API

Blasp mirrors the PHP PendingCheck surface: chain options, then call check(text) or checkMany(...).

Languages

blasp.in('spanish').check(text);
blasp.in('english', 'french').check(text);
blasp.inAllLanguages().check(text);

blasp.english().check(text);
blasp.spanish().check(text);
blasp.german().check(text);
blasp.french().check(text);

Drivers

blasp.driver('regex').check(text); // default; obfuscation, substitutions, separators
blasp.driver('pattern').check(text); // fast word-boundary exact match
blasp.driver('phonetic').check(text); // metaphone + Levenshtein (English-oriented)
blasp.driver('pipeline').check(text); // uses config `drivers.pipeline.drivers`

blasp.pipeline('regex', 'phonetic').check(text);

Modes

blasp.lenient().check(text); // forces the `pattern` driver (same as PHP)
blasp.strict().check(text); // clears lenient mode; included in the result cache key like PHP

Masking

blasp.mask('*').check(text);
blasp.mask('#').check(text);
blasp.mask('grawlix').check(text); // !@#$% rotation
blasp.mask((word, len) => '[CENSORED]').check(text);

Callback masks disable result caching (same idea as PHP: closures are not serializable).

Severity and lists

import { Severity } from '@antistatique/blaspjs';

blasp.withSeverity(Severity.High).check(text); // drops milder matches before masking

blasp.allow('damn', 'hell').check(text);
blasp.block('customword').check(text);

Batch

blasp.checkMany(['one', 'two']); // Result[]
blasp.checkMany({ a: 'x', b: 'y' }); // Record<string, Result>

Custom drivers

import type { Driver } from '@antistatique/blaspjs';

const myDriver: Driver = {
  detect(text, dictionary, mask, options) {
    /* return a Result */
  },
};

blasp.extend('my-driver', () => myDriver);
blasp.driver('my-driver').check(text);

Result

| Method | Returns | Description | | ---------------- | -------------------- | ------------------------------------ | | isOffensive() | boolean | Any profanity matched | | isClean() | boolean | No matches | | clean() | string | Masked text | | original() | string | Original input | | score() | number | 0–100 severity score | | count() | number | Match count | | uniqueWords() | string[] | Unique base words | | severity() | SeverityLevel \| null | Strongest severity among matches | | words() | MatchedWord[] | Positions, lengths, severity, etc. | | toArray() | object | JSON-friendly snapshot | | toJson() | string | JSON.stringify(toArray()) |

Legacy-style aliases from PHP v3 are available on Result (hasProfanity, getCleanString, …).

String(result) / template interpolation uses the clean string (like PHP Stringable).

Configuration

Pass a partial config to new Blasp(partialConfig); it is deep-merged with defaultBlaspConfig (see src/config/defaultConfig.ts and src/config/blasp-defaults.json).

Relevant keys include:

  • default — default driver name (regex, pattern, phonetic, pipeline)
  • language / default_language
  • mask / mask_character
  • allow, block, false_positives, separators, substitutions
  • drivers.pipeline.drivers, drivers.phonetic.*
  • cache.enabled, cache.results, cache.ttl

Middleware / Eloquent / Blade keys exist on the type for parity with PHP config shape; they are not used by this library.

Runtime options

import { Blasp, MemoryCache } from '@antistatique/blaspjs';

const blasp = new Blasp(undefined, {
  cache: new MemoryCache(), // or your own CacheAdapter; pass null to disable internal cache
  onProfanityDetected(result, originalText) {
    if (result.isOffensive()) {
      // logging, metrics, etc.
    }
  },
});

getCache() returns null when cache.enabled is false or runtime.cache === null.

Regenerating language data

Word lists and global separator/substitution defaults are vendored as JSON. To refresh from upstream Blaspsoft/blasp:

bun run export-languages

Requires curl and php on your PATH. This overwrites src/languages/*.json and src/config/blasp-defaults.json.

API parity vs PHP Blasp

| Feature | PHP (Blasp v4) | @antistatique/blaspjs | | ------- | ---------------------------------------------------- | ------- | | Drivers: regex, pattern, phonetic, pipeline | Yes | Yes | | Fluent PendingCheck API | Yes | Yes | | Result / MatchedWord, scoring, masking | Yes | Yes | | Multi-language dictionaries + normalizers | Yes | Yes | | Allow / block lists, severity filter | Yes | Yes | | Result caching (in-memory or custom) | Laravel cache | MemoryCache or CacheAdapter | | Custom drivers (extend) | Yes | Yes | | Laravel facade, service provider | Yes | No | | Middleware, validation rules, Blade | Yes | No | | Eloquent Blaspable, model events | Yes | No | | Artisan commands, Blasp::fake() | Yes | No |

For full behaviour and examples, see the upstream README.

Development

bun install
bun run build   # ESM + types in dist/
bun test        # Vitest
bun run lint:js

License

MIT. Profanity dictionaries and algorithmic behaviour are derived from Blaspsoft/blasp (MIT). This port is maintained separately and is not an official Blaspsoft package unless they choose to adopt it.