Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

activityspam-filter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activityspam-filter

Extraction and modernization of the filters in activityspam

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ActivitySpam Filter

Extraction and modernization of the filters in activityspam + a minimal databank reimplementation

npm version npm downloads js-semistandard-style Module type: ESM Types in JS Follow @voxpelli@mastodon.social

Usage

Simple

import { SpamFilter, SimpleDatabankRedis } from 'activityspam-filter';

// Configured like ioredis, so by default it will connect to localhost:6379
const redisDb = new SimpleDatabankRedis();
const filter = new SpamFilter(redisDb);

await filter.train('spam', foo);
await filter.train('ham', bar);
const { isSpam } = await filter.test(abc);

SpamFilter(db, [tokenizerOptions])

  • db – a SimpleDatabank compatible class such as the supplied SimpleDatabankRedis

SpamFilter API

train(category, data) => Promise<SpamFilterTrainingResult>

  • category – should be either spam or ham depending on what kind of content to train it with
  • data – should be an object or an array of the data that should be tokenized and trained on

Returns an object with properties:

  • cat – the supplied category
  • object – a stringified representation of the data that's been supplied
  • date – the ISO date this training data was created
  • elapsed – the amount of milliseconds the training took

test(data) => Promise<SpamFilterDecision>

  • data – should be an object or an array of the data that should be tokenized and tested

Returns an object with properties:

  • probability – a number
  • isSpam – a boolean
  • bestKeys – a list of the best tokens
  • elapsed – the amount of milliseconds the check took

SimpleDatabankRedis(ioRedisConfig)

Configured like ioredis and provides a SimpleDatabank compatible implementation of that.

Types

  • SimpleDatabank – the structure of a databank style implementation

See also

FAQs

Package last updated on 15 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc