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 🙏

© 2024 – Pkg Stats / Ryan Hefner

glin-profanity

v1.1.9

Published

Glin-Profanity is a lightweight and efficient npm package designed to detect and filter profane language in text inputs across multiple languages. Whether you’re building a chat application, a comment section, or any platform where user-generated content

Downloads

636

Readme

Glin Profanity

Glin-Profanity is a lightweight and efficient npm package designed to detect and filter profane language in text inputs across multiple languages. Whether you’re building a chat application, a comment section, or any platform where user-generated content is involved, Glin-Profanity helps you maintain a clean and respectful environment.

Installation

To install Glin-Profanity, use npm:

npm install glin-profanity

OR

yarn add glin-profanity

Usage

Basic Usage

Here's a simple example of how to use Glin-Profanity in a React application:

import React, { useState } from 'react';
import { useProfanityChecker, Language } from 'glin-profanity';

const App: React.FC = () => {
  const [text, setText] = useState('');
  const [checkAllLanguages, setCheckAllLanguages] = useState(false);
  const { result, checkText } = useProfanityChecker(
    checkAllLanguages ? { allLanguages: true } : { languages: ['english', 'french'] }
  );

  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    setText(e.target.value);
  };

  const handleCheck = () => {
    checkText(text);
  };

  return (
    <div>
      <h1>Welcome to Glin-Profanity</h1>
      <input type="text" value={text} onChange={handleChange} />
      <button onClick={handleCheck}>Check Profanity</button>
      <div>
        <label>
          <input
            type="checkbox"
            checked={checkAllLanguages}
            onChange={(e) => setCheckAllLanguages(e.target.checked)}
          />
          Check All Languages
        </label>
      </div>
      {result && (
        <div>
          <p>Contains Profanity: {result.containsProfanity ? 'Yes' : 'No'}</p>
          {result.containsProfanity && (
            <p>Profane Words: {result.profaneWords.join(', ')}</p>
          )}
        </div>
      )}
    </div>
  );
};

export default App;

API

Filter Class

Constructor

new Filter(config?: { 
  languages?: Language[]; 
  allLanguages?: boolean;
  caseSensitive?: boolean;
  wordBoundaries?: boolean;
  customWords?: string[];
  replaceWith?: string;
  severityLevels?: boolean; 
  ignoreWords?: string[];
  logProfanity?: boolean; 
});
  • config: An optional configuration object.
    • languages: An array of languages to check for profanities.
    • allLanguages: A boolean indicating whether to check for all languages.
    • caseSensitive: A boolean indicating whether the profanity check should be case-sensitive.
    • wordBoundaries: A boolean indicating whether to consider word boundaries when checking for profanities.
    • customWords: An array of custom words to include in the profanity check.
    • replaceWith: A string to replace profane words with.
    • severityLevels: A boolean indicating whether to include severity levels for profane words.
    • ignoreWords: An array of words to ignore in the profanity check.
    • logProfanity: A boolean indicating whether to log detected profane words.

Methods

isProfane

Checks if a given text contains profanities.

isProfane(value: string): boolean;
  • value: The text to check.
  • Returns: boolean - true if the text contains profanities, false otherwise.
checkProfanity

Returns details about profanities found in the text.

checkProfanity(text: string): CheckProfanityResult;
  • text: The text to check.
  • Returns: CheckProfanityResult
    • containsProfanity: boolean - true if the text contains profanities, false otherwise.
    • profaneWords: string[] - An array of profane words found in the text.
    • processedText: string - The text with profane words replaced (if replaceWith is specified).
    • severityMap: { [word: string]: number } - A map of profane words to their severity levels (if severityLevels is specified).

useProfanityChecker Hook

A custom React hook for using the profanity checker.

Parameters

  • config: An optional configuration object.
    • languages: An array of languages to check for profanities.
    • allLanguages: A boolean indicating whether to check for all languages.
    • caseSensitive: A boolean indicating whether the profanity check should be case-sensitive.
    • wordBoundaries: A boolean indicating whether to consider word boundaries when checking for profanities.
    • customWords: An array of custom words to include in the profanity check.
    • replaceWith: A string to replace profane words with.
    • severityLevels: A boolean indicating whether to include severity levels for profane words.
    • ignoreWords: An array of words to ignore in the profanity check.
    • logProfanity: A boolean indicating whether to log detected profane words.
    • customActions: A function to execute custom actions when profanity is detected.

Return Value

  • result: The result of the profanity check.
  • checkText: A function to check a given text for profanities.
  • checkTextAsync: A function to check a given text for profanities asynchronously.
const { result, checkText, checkTextAsync } = useProfanityChecker(config);

License

This software is also available under the GLINCKER LLC proprietary license. The proprietary license allows for use, modification, and distribution of the software with certain restrictions and conditions as set forth by GLINCKER LLC.

You are free to use this software for reference and educational purposes. However, any commercial use, distribution, or modification outside the terms of the MIT License requires explicit permission from GLINCKER LLC.

By using the software in any form, you agree to adhere to the terms of both the MIT License and the GLINCKER LLC proprietary license, where applicable. If there is any conflict between the terms of the MIT License and the GLINCKER LLC proprietary license, the terms of the GLINCKER LLC proprietary license shall prevail.

MIT License

GLIN PROFANITY is MIT licensed.