Skip to content

Commit eda8bcb

Browse files
Merge pull request #26 from coffee-and-fun/Version-3
Version 3
2 parents 913c34e + 429f255 commit eda8bcb

File tree

19 files changed

+2938
-199
lines changed

19 files changed

+2938
-199
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/.DS_Store

6 KB
Binary file not shown.

.github/readme.png

40.4 KB
Loading

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main, master ]
6+
push:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [16.x, 18.x, 20.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests
31+
run: npm test

README.md

Lines changed: 170 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,223 @@
11
![alt text](.github/readme.png 'Logo Title Text 1')
22

3-
## Description
43

5-
Full list of bad words and top swear words banned by Google. The list is updated monthly. Pull requests are welcome!
64

7-
The `@coffeeandfun/google-profanity-words` is a Node.js module created by Robert James Gabriel from Coffee & Fun LLC. It is designed to help you identify and manage profanity words in a given text. The module provides functions to retrieve a list of all known profanity words, check if a specific word is considered profane, and handle empty strings appropriately.
5+
# ☕ Google Profanity Words
86

9-
## Installation
7+
> A fun and developer-friendly profanity detection library brought to you by [Coffee & Fun LLC](https://coffeeandfun.com) ☕🎉
8+
> Built and maintained with love by [Robert James Gabriel](https://github.com/robertgabriel) 💻✨
109
11-
You can install the `@coffeeandfun/google-profanity-words` module using npm:
10+
[![npm version](https://img.shields.io/npm/v/@coffeeandfun/google-profanity-words.svg)](https://www.npmjs.com/package/@coffeeandfun/google-profanity-words) [![Stars](https://img.shields.io/github/stars/@coffeeandfun/google-profanity-words?style=social)](https://github.com/@coffeeandfun/google-profanity-words)
11+
12+
13+
---
14+
15+
## 🚀 What’s This?
16+
17+
**Google Profanity Words** is a Node.js library that helps you detect and filter out naughty language (in multiple languages!) from your apps or content. Whether you’re building a chat app, a comment section, or a game—this one’s your profanity-slaying sidekick.
18+
19+
Made by devs for devs. Maintained by Robert at Coffee & Fun ☕❤️
20+
21+
---
22+
23+
## ✨ Features
24+
25+
- 🌐 **Multilingual support** – English and Spanish out of the box. More coming soon!
26+
- 🔁 **Monthly updates** – Stay fresh with the latest no-no words
27+
- 💡 **Easy to use API** – Straightforward methods, async/await friendly
28+
- 🔬 **Tested with Jest** – Fully covered and ready for production
29+
-**Tiny & Fast** – Minimal deps = speedy installs and performance
30+
31+
---
32+
33+
## 📦 Install Me
1234

1335
```bash
1436
npm install @coffeeandfun/google-profanity-words
1537
```
1638

17-
## Usage
39+
---
1840

19-
To use the `@coffeeandfun/google-profanity-words`, first, import the module and create an instance:
41+
## ⚡ Quickstart Guide
2042

2143
```javascript
2244
import { ProfanityEngine } from '@coffeeandfun/google-profanity-words';
2345

24-
// Pass the 'language' parameter to specify the language (optional).
25-
// Defaults to 'en' if no valid language code is provided.
26-
const profanity = new ProfanityEngine({ language: 'es' });
46+
// Default is English
47+
const profanity = new ProfanityEngine();
48+
49+
// Español? You got it.
50+
const profanityES = new ProfanityEngine({ language: 'es' });
51+
52+
// Check a single word
53+
const isBad = await profanity.search('example');
54+
55+
// Or check a full sentence
56+
const hasCurses = await profanity.hasCurseWords('This is a test sentence');
57+
58+
console.log(isBad, hasCurses); // true / false
2759
```
2860

29-
The language parameter is optional and can be used to specify the language for the profanity list. It defaults to 'en' if no valid language code is provided. If the specified language file is not found, it will fall back to the 'en' language file and display a console warning.
61+
---
3062

31-
## API Functions
63+
## 🔍 API Docs (But Make It Chill)
3264

33-
### 1. `all()`
65+
### 🛠️ `new ProfanityEngine(options?)`
3466

35-
Retrieves all the profanity words as an array.
67+
Create a new profanity detector engine!
3668

3769
```javascript
38-
const allWords = await profanity.all();
70+
const profanity = new ProfanityEngine(); // Defaults to English
3971
```
4072

41-
### 2. `search(word)`
73+
Or choose a specific language:
4274

43-
Checks if a given word is considered profane.
75+
```javascript
76+
const spanishProfanity = new ProfanityEngine({ language: 'es' });
77+
```
78+
79+
#### Options:
80+
- `language` (string, optional):
81+
- `'en'` = English (default)
82+
- `'es'` = Spanish
83+
- If a language isn’t available, it falls back to English.
84+
85+
---
86+
87+
### 🔎 `search(word)`
88+
89+
Check a single word to see if it's naughty.
4490

4591
```javascript
46-
const searchWord = await profanity.search('shit');
47-
// Returns true if the word is profane, otherwise false.
92+
const isProfane = await profanity.search('heck');
93+
console.log(isProfane); // true or false
4894
```
4995

50-
### 3. hasCurseWords(sentence)
96+
---
97+
98+
### 💬 `hasCurseWords(sentence)`
5199

52-
Checks if a given sentence contains any profanity words.
100+
Check a full sentence or phrase for profanity.
53101

54102
```javascript
55-
const sentence = 'Do not use bad words like mierda or idiota.';
56-
const hasCurseWords = await profanity.hasCurseWords(sentence);
57-
// Returns true if the sentence contains profanity words, otherwise false.
103+
const result = await profanity.hasCurseWords('You silly goose');
104+
console.log(result); // probably false, unless goose is banned now 🪿
58105
```
59106

60-
### 4. Handling Empty Strings
107+
---
108+
109+
### 📜 `all()`
61110

62-
The `search` and `hasCurseWords` functions will return false for any empty string.
111+
Get the full list of bad words in the current language.
63112

64113
```javascript
65-
const searchWord = await profanity.search('');
66-
const hasCurseWords = await profanity.hasCurseWords('');
67-
// Returns false for an empty string.
114+
const badWords = await profanity.all();
115+
console.log(badWords); // ['word1', 'word2', 'etc']
68116
```
69117

70-
## Testing
118+
---
119+
120+
### 💡 Real Talk: Edge Cases
121+
122+
- Empty strings? We gotchu. Returns `false`.
123+
- `search()` and `hasCurseWords()` are **case-insensitive**.
124+
- Special characters and punctuation? No problem.
125+
126+
---
127+
128+
## 🧪 Testing with Jest
71129

72-
The `@coffeeandfun/google-profanity-words` comes with a test suite using the Jest framework. To run the tests, use the following command:
130+
We've got testing covered like whipped cream on a latte ☕🎂
131+
132+
Run the default test suite:
73133

74134
```bash
75135
npm test
76136
```
77137

78-
## Contributing
138+
Or use more specific Jest commands:
139+
140+
```bash
141+
# Watch mode (great for dev workflow)
142+
npx jest --watch
143+
144+
# Run tests in a specific file
145+
npx jest path/to/your/file.test.js
146+
147+
# Run coverage report
148+
npx jest --coverage
149+
150+
# Run with verbose output (get all the juicy details)
151+
npx jest --verbose
152+
```
153+
154+
Tests are located in the `/__tests__/` directory and use the real profanity files, so you know it’s legit 👀✅
155+
156+
---
157+
158+
## 🔀 Example Use Cases
159+
160+
### ✅ Filter User Input
161+
162+
```js
163+
async function filterInput(input) {
164+
if (await profanity.hasCurseWords(input)) {
165+
return '⚠️ Whoa there! Language, please.';
166+
}
167+
return input;
168+
}
169+
```
170+
171+
---
172+
173+
### 🌍 Multi-language Setup
174+
175+
```js
176+
const en = new ProfanityEngine({ language: 'en' });
177+
const es = new ProfanityEngine({ language: 'es' });
178+
179+
const englishResult = await en.search('bad');
180+
const spanishResult = await es.search('malo');
181+
```
182+
183+
---
184+
185+
## 🌍 Want to Contribute?
186+
187+
We love open source buddies 💛
188+
189+
### Add a New Language
190+
191+
1. Fork it 🍴
192+
2. Add a file to `/data/` named like `fr.txt` for French
193+
3. Fill it with one profane word per line
194+
4. Push & open a pull request!
195+
196+
---
197+
198+
## 🙌 Who Made This?
79199

80-
Contributions to this module are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request on the GitHub repository.
200+
Built by [Robert James Gabriel](https://github.com/robertgabriel) and the good people at **Coffee & Fun LLC**. We make dev tools with accessibility, coffee, and good vibes in mind.
81201

82-
## License
202+
> Wanna support? Send a coffee our way or just spread the word! ☕🚀
83203
84-
This project is licensed under the MIT License.
204+
---
85205

86-
## Acknowledgments
206+
## 🧡 License
87207

88-
Special thanks to Robert James Gabriel and Coffee & Fun LLC for creating and maintaining this module, as well as the Jest team for the testing framework. Your efforts make this module more reliable and robust.
208+
[MIT](https://opensource.org/licenses/MIT) – because sharing is caring.
89209

90210
---
211+
212+
## 💬 Support & Community
213+
214+
- 🐛 [Report Bugs](https://github.com/coffeeandfun/google-profanity-words/issues)
215+
- 💡 [Join Discussions](https://github.com/coffeeandfun/google-profanity-words/discussions)
216+
- 📬 Email: [support@coffeeandfun.com](mailto:hellow@coffeeandfun.com)
217+
218+
---
219+
220+
Made with ☕, code, and a sprinkle of magic at Coffee & Fun LLC 💖
221+
222+
## AI Usage
223+
Calude AI was used to help with this read me & adding extra Jest tests.

0 commit comments

Comments
 (0)