From 5edaf6be528a3dcd97e99b9bae5ffe9a6e25e96c Mon Sep 17 00:00:00 2001 From: GDS K S <39922405+gagandua078@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:35:57 -0500 Subject: [PATCH] Types Shipping --- .gitignore | 2 +- package.json | 4 ++-- src/index.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/index.d.ts diff --git a/.gitignore b/.gitignore index 6d9bfc9..883a076 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ build/ # TypeScript compiled output *.tsbuildinfo - +!src/index.d.ts # Logs logs/ *.log diff --git a/package.json b/package.json index 4690f74..0f8e0e3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..40fe307 --- /dev/null +++ b/src/index.d.ts @@ -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; + }; + } + \ No newline at end of file