ts-sensitivewords 1.0.0 → 1.0.1-beta.3

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -1
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Taskeren
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
1
  # TS-SensitiveWords
2
2
 
3
- A TypeScript rewrite of [alex-my/js-sensitivewords](https://github.com/alex-my/js-sensitivewords).
3
+ [![](https://img.shields.io/npm/v/ts-sensitivewords)](https://www.npmjs.com/package/ts-sensitivewords)
4
+
5
+ TypeScript rewrite of [alex-my/js-sensitivewords](https://github.com/alex-my/js-sensitivewords).
6
+
7
+ A small TypeScript library for sensitive word detection using a simple DFA (trie) implementation. It provides adding words, detecting presence, finding matches and masking sensitive words for quick integration into applications.
8
+
9
+ ## Features
10
+
11
+ - Add sensitive words: `addWords(...words: string[])`
12
+ - Check if content contains any sensitive word: `contains(content: string): boolean`
13
+ - Check match length from a position: `check(content: string, startIndex?: number): number`
14
+ - Find all matches in content: `find(content: string, startIndex?: number): string[]`
15
+ - Mask detected sensitive words: `mask(content: string, mask?: string): string`
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install ts-sensitivewords
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ 1) Use the default exported instance:
26
+
27
+ ```ts
28
+ import sw from 'ts-sensitivewords'
29
+
30
+ sw.addWords('sensitive1', 'sensitive2')
31
+ console.log(sw.contains('This text contains sensitive1')) // true
32
+ console.log(sw.mask('This text contains sensitive1')) // "This text contains **********"
33
+ ```
34
+
35
+ 2) Create an independent instance:
36
+
37
+ ```ts
38
+ import { SensitiveWords } from 'ts-sensitivewords' // or import { SensitiveWords } from './src'
39
+
40
+ const s = new SensitiveWords()
41
+ s.addWords('foo', 'bar')
42
+ console.log(s.find('foo and bar and foo')) // ['foo','bar','foo']
43
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ts-sensitivewords",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.1-beta.3",
5
5
  "description": "A DFA map implementation for sensitive words matching and blocking.",
6
6
  "author": "Taskeren",
7
7
  "license": "MIT",