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

@suhadahmodkhan/no-bad-words

v1.1.3

Published

no inappropriate words

Downloads

5

Readme

No Bad Words - Inappropriate Word Checker

A simple and lightweight npm package to check for inappropriate words (bad words) in a sentence or paragraph. It detects if any words from a predefined list of bad words are present and returns the list of bad words along with their count.

Installation

To install the package, run the following command in your terminal:

npm install @suhadahmodkhan/no-bad-words

Usage

Importing the Package

First, import the checkInappropriate function from the package in your JavaScript or TypeScript file:

import checkInappropriate from "@suhadahmodkhan/no-bad-words";

Checking for Inappropriate Words

The checkInappropriate function checks if a sentence or paragraph contains any inappropriate words. It returns a promise that resolves to an object containing the list of bad words found and their count.

Example 1: Basic Usage

import checkInappropriate from "@suhadahmodkhan/no-bad-words";


const check =  checkInappropriate("This is a bad sentence with some inappropriate words.");
console.log(check);

Example 2: Handling the Result

The checkInappropriate function returns an object with the following structure:


{
  hasBadWords: true, // or false if no bad words are found
  badWords: ["bad", "inappropriate"], // list of bad words found
  badCount: 2 // number of bad words found
}

You can handle the result as follows:


import checkInappropriate from "@suhadahmodkhan/no-bad-words";

const checkSentence =  (sentence) => {
  const result =  checkInappropriate(sentence);

  if (result.hasBadWords) {
    console.log(`Bad words found: ${result.badWords.join(", ")}`);
    console.log(`Total bad words: ${result.count}`);
  } else {
    console.log("No bad words found.");
  }
};

checkSentence("This is a clean sentence.");

Example 3: Using in a React Component

You can also use this package in a React component to check for inappropriate words in user input:


import React, { useState } from "react";
import checkInappropriate from "@suhadahmodkhan/no-bad-words";

const App = () => {
  const [input, setInput] = useState("");
  const [result, setResult] = useState(null);

  const handleCheck =  () => {
    const checkResult =  checkInappropriate(input);
    setResult(checkResult);
  };

  return (
    <div>
      <textarea
        value={input}
        onChange={(e) => setInput(e.target.value)}
        placeholder="Enter your text here..."
      />
      <button onClick={handleCheck}>Check for Bad Words</button>

      {result && (
        <div>
          {result.hasBadWords ? (
            <p>
              Bad words found: {result.badWords.join(", ")} (Count: {result.count})
            </p>
          ) : (
            <p>No bad words found.</p>
          )}
        </div>
      )}
    </div>
  );
};

export default App;

API Reference

checkInappropriate(sentence: string): { hasBadWords: boolean, badWords: string[], count: number } sentence: The sentence or paragraph to check for inappropriate words.

hasBadWords: A boolean indicating whether bad words were found.

badWords: An array of bad words found in the sentence.

badCount: The total number of bad words found.