@useverse/profanity-guard 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/index.js +3998 -2365
- package/dist/index.mjs +3998 -2365
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -241,10 +241,10 @@ import {
|
|
|
241
241
|
mild_bad_words,
|
|
242
242
|
moderate_bad_words,
|
|
243
243
|
severe_bad_words
|
|
244
|
-
} from '
|
|
244
|
+
} from 'profanity-guard/core/library';
|
|
245
245
|
|
|
246
246
|
// Import only severe words
|
|
247
|
-
const moderator = new
|
|
247
|
+
const moderator = new ProfanityGuard();
|
|
248
248
|
moderator.clearLibrary(); // Remove defaults
|
|
249
249
|
moderator.importLibrary(severe_bad_words);
|
|
250
250
|
```
|
|
@@ -262,7 +262,7 @@ console.log(`Severe: ${stats.severe}`);
|
|
|
262
262
|
### Quick Moderate (One-off Use)
|
|
263
263
|
|
|
264
264
|
```typescript
|
|
265
|
-
import { quickModerate, ModerationLevel } from '
|
|
265
|
+
import { quickModerate, ModerationLevel } from 'profanity-guard';
|
|
266
266
|
|
|
267
267
|
const result = quickModerate("Some text", ModerationLevel.STRICT);
|
|
268
268
|
```
|
|
@@ -271,7 +271,7 @@ const result = quickModerate("Some text", ModerationLevel.STRICT);
|
|
|
271
271
|
|
|
272
272
|
### Obfuscation Detection
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
ProfanityGuard automatically detects common character substitutions:
|
|
275
275
|
|
|
276
276
|
```typescript
|
|
277
277
|
moderator.isClean("sh!t"); // false - detects ! as i
|
|
@@ -400,7 +400,7 @@ import {
|
|
|
400
400
|
quickSanitize,
|
|
401
401
|
quickScore,
|
|
402
402
|
quickValidate
|
|
403
|
-
} from '
|
|
403
|
+
} from 'profanity-guard';
|
|
404
404
|
|
|
405
405
|
// Quick checks
|
|
406
406
|
if (quickCheck("Hello world")) {
|
|
@@ -420,7 +420,7 @@ const isValid = quickValidate(content, {
|
|
|
420
420
|
});
|
|
421
421
|
```
|
|
422
422
|
|
|
423
|
-
> **Note:** Quick utilities are convenient but less efficient for repeated use. For better performance with multiple operations, create a
|
|
423
|
+
> **Note:** Quick utilities are convenient but less efficient for repeated use. For better performance with multiple operations, create a ProfanityGuard instance and reuse it.
|
|
424
424
|
|
|
425
425
|
### Match Details
|
|
426
426
|
|
|
@@ -455,15 +455,15 @@ Full TypeScript support with comprehensive type definitions:
|
|
|
455
455
|
|
|
456
456
|
```typescript
|
|
457
457
|
import {
|
|
458
|
-
|
|
458
|
+
ProfanityGuard,
|
|
459
459
|
ModerationLevel,
|
|
460
460
|
WordSeverity,
|
|
461
461
|
ModerationResult,
|
|
462
462
|
WordEntry,
|
|
463
463
|
Match
|
|
464
|
-
} from '
|
|
464
|
+
} from 'profanity-guard';
|
|
465
465
|
|
|
466
|
-
const moderator:
|
|
466
|
+
const moderator: ProfanityGuard = new ProfanityGuard();
|
|
467
467
|
const result: ModerationResult = moderator.moderate("text");
|
|
468
468
|
const entry: WordEntry = {
|
|
469
469
|
word: "example",
|
|
@@ -474,11 +474,11 @@ const entry: WordEntry = {
|
|
|
474
474
|
|
|
475
475
|
## 📚 API Reference
|
|
476
476
|
|
|
477
|
-
###
|
|
477
|
+
### ProfanityGuard Class
|
|
478
478
|
|
|
479
479
|
#### Constructor
|
|
480
480
|
```typescript
|
|
481
|
-
new
|
|
481
|
+
new ProfanityGuard(moderationLevel?: ModerationLevel, censorChar?: string)
|
|
482
482
|
```
|
|
483
483
|
|
|
484
484
|
#### Core Methods
|
|
@@ -580,7 +580,7 @@ new NoBadWord(moderationLevel?: ModerationLevel, censorChar?: string)
|
|
|
580
580
|
### Comment Moderation
|
|
581
581
|
```typescript
|
|
582
582
|
function moderateComment(comment: string): string {
|
|
583
|
-
const moderator = new
|
|
583
|
+
const moderator = new ProfanityGuard(ModerationLevel.MODERATE);
|
|
584
584
|
const result = moderator.moderate(comment);
|
|
585
585
|
|
|
586
586
|
if (!result.isClean) {
|
|
@@ -594,7 +594,7 @@ function moderateComment(comment: string): string {
|
|
|
594
594
|
### Chat Filter
|
|
595
595
|
```typescript
|
|
596
596
|
function filterChatMessage(message: string): { allowed: boolean; filtered: string } {
|
|
597
|
-
const moderator = new
|
|
597
|
+
const moderator = new ProfanityGuard(ModerationLevel.STRICT);
|
|
598
598
|
const result = moderator.moderateSentence(message, true);
|
|
599
599
|
|
|
600
600
|
return {
|
|
@@ -607,7 +607,7 @@ function filterChatMessage(message: string): { allowed: boolean; filtered: strin
|
|
|
607
607
|
### User-Generated Content
|
|
608
608
|
```typescript
|
|
609
609
|
function validateUsername(username: string): { valid: boolean; reason?: string } {
|
|
610
|
-
const moderator = new
|
|
610
|
+
const moderator = new ProfanityGuard(ModerationLevel.STRICT);
|
|
611
611
|
|
|
612
612
|
if (!moderator.isClean(username)) {
|
|
613
613
|
return { valid: false, reason: 'Username contains inappropriate language' };
|
|
@@ -1284,9 +1284,9 @@ MIT © [Your Name]
|
|
|
1284
1284
|
|
|
1285
1285
|
## 🔗 Links
|
|
1286
1286
|
|
|
1287
|
-
- [Documentation](https://github.com/yourusername/
|
|
1288
|
-
- [NPM Package](https://www.npmjs.com/package/
|
|
1289
|
-
- [Issue Tracker](https://github.com/yourusername/
|
|
1287
|
+
- [Documentation](https://github.com/yourusername/profanity-guard#readme)
|
|
1288
|
+
- [NPM Package](https://www.npmjs.com/package/profanity-guard)
|
|
1289
|
+
- [Issue Tracker](https://github.com/yourusername/profanity-guard/issues)
|
|
1290
1290
|
|
|
1291
1291
|
## ⚠️ Disclaimer
|
|
1292
1292
|
|