🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@therohitdas/profanityjs

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

@therohitdas/profanityjs

Simple profanity filter and masker.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

Profanity JS

Simple profanity filter and masker.

Installation

npm install @therohitdas/profanityjs

Usage

ProfanityJs comes with two functions:

  • containsProfanity(sentence, useHomoglyphSearch): This function takes two required arguments.

    • sentence can be a word/ sentence/ paragraph which you want to check.
    • useHomoglyphSearch should be set true for now. In the future, I will add a method to checkProfanity without using glyph and better search time.

    It returns true if the sentence contains at least one naughty word, false otherwise.

const { containsProfanity } = require("@therohitdas/profanityjs");

var testSentence = "Go fuck yourself!";

if (containsProfanity(testSentence, true)) {
  console.log("Naughty word(s) detected");
} else {
  console.log("Clean :)");
}
// Output -
// Naughty word(s) detected
  • maskProfanity(sentence, mask): This function takes two arguments.

    • sentence can be a word/ sentence/ paragraph from which you want to check and mask the naughty word(s).
    • mask is the character with which you want to mask the naughty word. Default is "*".

    It returns the sentence with all the naughty words masked with the mask character. If there are no naughty words, it returns the input sentence unchanged.

const { maskProfanity } = require("@therohitdas/profanityjs");

var testSentence = "Go fuck yourself!";

var maskedSentence = maskProfanity(testSentence);
console.log(maskedSentence); // Output - Go **** yourself!

maskedSentence = maskProfanity(testSentence, "#");
console.log(maskedSentence); // Output - Go #### yourself!

Contribution

All contributions are welcome to improve this project.

Keywords

profanity

FAQs

Package last updated on 05 Apr 2021

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