Skip to content

Commit

Permalink
Types Shipping
Browse files Browse the repository at this point in the history
  • Loading branch information
thegdsks committed Aug 3, 2024
1 parent 1267229 commit 5edaf6b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build/

# TypeScript compiled output
*.tsbuildinfo

!src/index.d.ts
# Logs
logs/
*.log
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "glin-profanity",
"version": "1.1.2",
"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.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack serve --mode development",
Expand Down
36 changes: 36 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare module 'glin-profanity' {
export type Language = 'english' | 'french' | 'spanish' | 'german' | 'italian' | 'portuguese' | 'russian' | 'japanese' | 'chinese' | 'korean';

export interface CheckProfanityResult {
containsProfanity: boolean;
profaneWords: string[];
processedText?: string;
severityMap?: { [word: string]: number };
}

export interface ProfanityCheckerConfig {
languages?: Language[];
allLanguages?: boolean;
caseSensitive?: boolean;
wordBoundaries?: boolean;
customWords?: string[];
replaceWith?: string;
severityLevels?: boolean;
ignoreWords?: string[];
logProfanity?: boolean;
customActions?: (result: CheckProfanityResult) => void;
}

export class Filter {
constructor(config?: ProfanityCheckerConfig);
isProfane(value: string): boolean;
checkProfanity(text: string): CheckProfanityResult;
}

export function useProfanityChecker(config?: ProfanityCheckerConfig): {
result: CheckProfanityResult | null;
checkText: (text: string) => void;
checkTextAsync: (text: string) => Promise<CheckProfanityResult>;
};
}

0 comments on commit 5edaf6b

Please sign in to comment.