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

@_redsocs/spam-warden

v0.69.1

Published

Lightweight client-side JavaScript library for real-time spam detection. Trained on Thai spam data using Bernoulli Naive Bayes.

Downloads

316

Readme

SpamWarden.js

Lightweight, client-side JavaScript library for detecting spam and sentence hijacking in real-time. Trained on the model from RedSocs/spam-labeler, bundled for zero-dependency browser usage.

CI npm Socket Badge

Quick Start

Install

# npm
npm install @_redsocs/spam-warden

# Or download from CDN / GitHub releases

In the Browser

<!-- Option 1: From RedSocs CDN -->
<script src="https://redsocs.com/js/spam-warden.js"></script>

<!-- Option 2: Self-hosted -->
<script src="dist/spamwarden.min.js"></script>

<script>
  const result = window.spamwarden.spamcheck("สมัครสมาชิกวันนี้ รับโบนัส ฟรี!");
  console.log(result.isSpam);   // true
  console.log(result.prob);     // 1.0
  console.log(result.version);  // "v0.69"
</script>

As ES Module

import SpamWarden from './dist/spamwarden.min.js';
SpamWarden.spamcheck("Welcome bonus! Deposit now");

Quick Boolean Check

if (spamwarden.isSpam(userInput)) {
  // block or flag
}

In Node.js

const spamwarden = require("./dist/spamwarden.min.js");
const r = spamwarden.spamcheck("Welcome bonus! Deposit now get 200% match");
console.log(r.isSpam); // true

API

spamwarden.spamcheck(text) → object

| Field | Type | Description | |-------|------|-------------| | isSpam | boolean | true if detected as spam | | prob | number | Spam probability (0.0–1.0) | | reason | string? | Present if hard-rule triggered: "currency_symbol" or "spam_link" | | version | string | Model version (e.g., "v0.69") |

spamwarden.isSpam(text) → boolean

Convenience wrapper — returns only the boolean result.

spamwarden.version → string

Current model version string.

Build

# 1. Copy model from spam-labeler
cp ../spam-labeler/extension/model.json .

# 2. Build (bundles model into JS)
node build.js
# or: ./build.sh

Output:

| File | Size | |------|------| | dist/spamwarden.js | 3.5 MB (uncompressed) | | dist/spamwarden.min.js | 61 KB (minified) | | dist/spamwarden.min.js (gzipped) | 27 KB |

Optional: Better Minification

npm install terser
node build.js   # now uses terser instead of simple minification

How It Works

User posts text
    ↓
spamwarden.spamcheck(text)
    ↓
Hard rules check (currency symbols, spam links)
    ↓
Vectorizer: whitespace tokens + trigrams + quadgrams
    ↓
Bernoulli Naive Bayes prediction (class 0 = safe, 1 = spam)
    ↓
Softmax → probability
    ↓
{ isSpam, prob, version }

Model

| Property | Value | |----------|-------| | Origin | RedSocs/spam-labeler (Rust, Bernoulli NB) | | Features | ~63,000 tokens (whitespace + trigrams + quadgrams) | | Version | v0.69 (680 training samples) | | Hard Rules | Currency symbols ($€£฿) → auto-spam; Spam links (line.me, @line, lin.ee) → auto-spam |

Train Your Own Model

The model in this repo was trained by RedSocs/spam-labeler. To customize for your own use case:

# 1. Clone the training repo
git clone https://github.com/RedSocs/spam-labeler.git

# 2. Add your own training data
cp your-spam.txt spam-labeler/data/spam.txt
cp your-safe.txt spam-labeler/data/safe.txt

# 3. Retrain and export
cd spam-labeler
cargo run --release --bin export_model
cp extension/model.json ../spam-warden/model.json

# 4. Rebuild SpamWarden
cd ../spam-warden
node build.js

See the spam-labeler README for the full training pipeline.

Privacy

All processing happens in-memory in the browser. No data is sent to any server.

Related

  • RedSocs/spam-labeler — Rust-based training pipeline, TUI app, and Firefox extension for collecting and training the spam detection model.

Project Structure

spam-warden/
├── src/
│   └── spamwarden.js    # Library source (MODEL_DATA_PLACEHOLDER)
├── dist/
│   ├── spamwarden.js    # Bundled (model inlined, ~3.5 MB)
│   └── spamwarden.min.js # Minified for production (~61 KB, 27 KB gzipped)
├── model.json           # Trained model from spam-labeler
├── build.js             # Node.js build script
├── build.sh             # Shell wrapper
└── README.md            # This file