Skip to content

Commit d2f6209

Browse files
authored
Feat/release 1.1.3 (#17)
* Release v1.1.3 * Docs Fix
1 parent def866b commit d2f6209

File tree

4 files changed

+176
-7
lines changed

4 files changed

+176
-7
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "glin-profanity",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "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.",
55
"private": true,
66
"workspaces": [
@@ -27,7 +27,7 @@
2727
"author": "gdsks",
2828
"license": "ISC",
2929
"dependencies": {
30-
"glin-profanity": "^1.1.2",
30+
"glin-profanity": "^1.1.4",
3131
"react": "^18.3.1",
3232
"react-dom": "^18.3.1"
3333
},

packages/glin-profanity/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
2+
# Glin Profanity
3+
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.
4+
5+
## Installation
6+
7+
To install Glin-Profanity, use npm:
8+
9+
```bash
10+
npm install glin-profanity
11+
```
12+
OR
13+
14+
```bash
15+
yarn add glin-profanity
16+
```
17+
## Usage
18+
19+
### Basic Usage
20+
21+
Here's a simple example of how to use Glin-Profanity in a React application:
22+
23+
```typescript
24+
import React, { useState } from 'react';
25+
import { useProfanityChecker, Language } from 'glin-profanity';
26+
27+
const App: React.FC = () => {
28+
const [text, setText] = useState('');
29+
const [checkAllLanguages, setCheckAllLanguages] = useState(false);
30+
const { result, checkText } = useProfanityChecker(
31+
checkAllLanguages ? { allLanguages: true } : { languages: ['english', 'french'] }
32+
);
33+
34+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35+
setText(e.target.value);
36+
};
37+
38+
const handleCheck = () => {
39+
checkText(text);
40+
};
41+
42+
return (
43+
<div>
44+
<h1>Welcome to Glin-Profanity</h1>
45+
<input type="text" value={text} onChange={handleChange} />
46+
<button onClick={handleCheck}>Check Profanity</button>
47+
<div>
48+
<label>
49+
<input
50+
type="checkbox"
51+
checked={checkAllLanguages}
52+
onChange={(e) => setCheckAllLanguages(e.target.checked)}
53+
/>
54+
Check All Languages
55+
</label>
56+
</div>
57+
{result && (
58+
<div>
59+
<p>Contains Profanity: {result.containsProfanity ? 'Yes' : 'No'}</p>
60+
{result.containsProfanity && (
61+
<p>Profane Words: {result.profaneWords.join(', ')}</p>
62+
)}
63+
</div>
64+
)}
65+
</div>
66+
);
67+
};
68+
69+
export default App;
70+
```
71+
72+
## API
73+
74+
### `Filter` Class
75+
76+
#### Constructor
77+
78+
```typescript
79+
new Filter(config?: {
80+
languages?: Language[];
81+
allLanguages?: boolean;
82+
caseSensitive?: boolean;
83+
wordBoundaries?: boolean;
84+
customWords?: string[];
85+
replaceWith?: string;
86+
severityLevels?: boolean;
87+
ignoreWords?: string[];
88+
logProfanity?: boolean;
89+
});
90+
```
91+
92+
- `config`: An optional configuration object.
93+
- `languages`: An array of languages to check for profanities.
94+
- `allLanguages`: A boolean indicating whether to check for all languages.
95+
- `caseSensitive`: A boolean indicating whether the profanity check should be case-sensitive.
96+
- `wordBoundaries`: A boolean indicating whether to consider word boundaries when checking for profanities.
97+
- `customWords`: An array of custom words to include in the profanity check.
98+
- `replaceWith`: A string to replace profane words with.
99+
- `severityLevels`: A boolean indicating whether to include severity levels for profane words.
100+
- `ignoreWords`: An array of words to ignore in the profanity check.
101+
- `logProfanity`: A boolean indicating whether to log detected profane words.
102+
103+
#### Methods
104+
105+
##### `isProfane`
106+
107+
Checks if a given text contains profanities.
108+
109+
```typescript
110+
isProfane(value: string): boolean;
111+
```
112+
113+
- `value`: The text to check.
114+
- Returns: `boolean` - `true` if the text contains profanities, `false` otherwise.
115+
116+
##### `checkProfanity`
117+
118+
Returns details about profanities found in the text.
119+
120+
```typescript
121+
checkProfanity(text: string): CheckProfanityResult;
122+
```
123+
124+
- `text`: The text to check.
125+
- Returns: `CheckProfanityResult`
126+
- `containsProfanity`: `boolean` - `true` if the text contains profanities, `false` otherwise.
127+
- `profaneWords`: `string[]` - An array of profane words found in the text.
128+
- `processedText`: `string` - The text with profane words replaced (if `replaceWith` is specified).
129+
- `severityMap`: `{ [word: string]: number }` - A map of profane words to their severity levels (if `severityLevels` is specified).
130+
131+
### `useProfanityChecker` Hook
132+
133+
A custom React hook for using the profanity checker.
134+
135+
#### Parameters
136+
137+
- `config`: An optional configuration object.
138+
- `languages`: An array of languages to check for profanities.
139+
- `allLanguages`: A boolean indicating whether to check for all languages.
140+
- `caseSensitive`: A boolean indicating whether the profanity check should be case-sensitive.
141+
- `wordBoundaries`: A boolean indicating whether to consider word boundaries when checking for profanities.
142+
- `customWords`: An array of custom words to include in the profanity check.
143+
- `replaceWith`: A string to replace profane words with.
144+
- `severityLevels`: A boolean indicating whether to include severity levels for profane words.
145+
- `ignoreWords`: An array of words to ignore in the profanity check.
146+
- `logProfanity`: A boolean indicating whether to log detected profane words.
147+
- `customActions`: A function to execute custom actions when profanity is detected.
148+
149+
#### Return Value
150+
151+
- `result`: The result of the profanity check.
152+
- `checkText`: A function to check a given text for profanities.
153+
- `checkTextAsync`: A function to check a given text for profanities asynchronously.
154+
155+
```typescript
156+
const { result, checkText, checkTextAsync } = useProfanityChecker(config);
157+
```
158+
159+
## License
160+
161+
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.
162+
163+
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.
164+
165+
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.
166+
167+
### MIT License
168+
169+
GLIN PROFANITY is [MIT licensed](./LICENSE).

packages/glin-profanity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "glin-profanity",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "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.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

0 commit comments

Comments
 (0)