An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
![NPM Unpacked Size (with version)](https://img.shields.io/npm/unpacked-size/text-warden/0.2.1)
![GitHub Release](https://img.shields.io/github/v/release/sandeep-shome/text-warden)
![NPM Downloads](https://img.shields.io/npm/dm/text-warden)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/sandeep-shome/text-warden/release.yml)

# 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