https://github.com/sandeep-shome/text-warden
A lightweight utility library for detecting and sanitizing sensitive or unsafe text content in strings.
https://github.com/sandeep-shome/text-warden
changesets commitizen commitlint eslint lint-staged nodejs npm-package prettier tsup typescript
Last synced: 6 months ago
JSON representation
A lightweight utility library for detecting and sanitizing sensitive or unsafe text content in strings.
- Host: GitHub
- URL: https://github.com/sandeep-shome/text-warden
- Owner: sandeep-shome
- License: mit
- Created: 2025-07-07T06:34:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-09T09:52:26.000Z (11 months ago)
- Last Synced: 2025-07-09T10:41:11.132Z (11 months ago)
- Topics: changesets, commitizen, commitlint, eslint, lint-staged, nodejs, npm-package, prettier, tsup, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/text-warden
- Size: 99.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://choosealicense.com/licenses/mit/)




# text-warden
A lightweight utility library for detecting and sanitizing sensitive or unsafe text content in strings. Ideal for filtering offensive words, enforcing content policies, or building text moderation features in Node.js and frontend applications
## π Features
- π Simple `isSafeText` function to check for unsafe or banned words.
- β‘ Lightweight and fast β no dependencies.
- π§© Easily extensible for custom word lists or rules.
## β¬οΈ Installation
Install text-warden with npm
```bash
md my-app
cd my-app
npm install text-warden
```
## πΏ Usage/Examples
```javascript
import { isSafeText } from 'text-warden';
const result = isSafeText('Hello world!');
console.log(result); // true or false based on content
```
## π§° Functions/Methods
Usage and parameter list of all available functions
### `isSafeText()`
Checks if the given text is safe by detecting unsafe or profane words
```javascript
import { isSafeText } from 'text-warden';
const customOptions = {
extendUnsafeWords: ['foo', 'bar'],
};
const result = isSafeText('Foo is bad', customOptions);
console.log(result); // false
```
| Parameter | Type | Required | Description |
| ------------------------- | ---------- | -------- | --------------------------------------------------------------------------- |
| **text** | `string` | `true` | The input text to validate for unsafe or sensitive words. |
| extendUnsafeWords | `string[]` | `false` | Adds additional words to the list of unsafe words. Useful for custom rules. |
| skipChecksFor | `string[]` | `false` | Words to exclude from being flagged, even if they appear in unsafe lists. |
| disableDefaultUnsafeWords | `boolean` | `false` | Set to true to ignore the built-in list of unsafe words. |
## π€ Contribution
Contributions are welcome and appreciated!
If you have suggestions for improvements, feel free to open an issue or submit a pull request.
Letβs make text-warden better together! πβ¨
## π Run Locally
Clone the project
```bash
git clone https://github.com/sandeep-shome/text-warden.git
```
Go to the project directory
```bash
cd text-warden
```
π§ Install dependencies
```bash
npm install
```
_You can now explore and modify the package as per your needs._
π¦ Build the Project
```bash
npm run build
```
## π§ͺ Running Tests
Follow the steps below to run and verify the functionality of the CLI and validation logic.
```bash
npm run test
```
## π§ Built With
- [**TypeScript**](https://www.typescriptlang.org/) β Strongly typed language for scalable JavaScript development
- [**Vitest**](https://vitest.dev/) β Fast unit testing framework with great DX
- [**tsup**](https://tsup.egoist.dev/) β Super-fast TypeScript bundler powered by esbuild
## πAppendix
text-warden is an open-source project developed and maintained by a solo developer with a passion for clean code, creativity, and community-driven tools.
You're welcome to explore, use, and contribute to the project! Whether it's fixing a bug, suggesting a feature, or improving the documentation β your contributions are highly appreciated.
Feel free to check out the GitHub repository and join in making this project better for everyone. Let's build something fun together! π‘
## π¨βπ» Authors
[@Sandeep Shome](https://github.com/sandeep-shome)
## π License
[MIT](https://choosealicense.com/licenses/mit/)
## πββοΈ Support
For support, email sandeepshome.dev@gmail.com