JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12912
  • Score
    100M100P100Q168814F
  • License ISC

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.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glin-profanity) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    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

    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 });
    • config: An optional configuration object.
      • languages: An array of languages to check for profanities.
      • allLanguages: A boolean indicating whether to check for all languages.

    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.

    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.

    Return Value

    • result: The result of the profanity check.
    • checkText: A function to check a given text for profanities.
    const { result, checkText } = 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.