@bharanidharan-alt/censorify 0.1.0
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.
- package/README.md +1 -0
- package/censorify-0.1.0.tgz +0 -0
- package/censortext.js +26 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CENSORIFY
|
|
Binary file
|
package/censortext.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
let censoredWords = ["bad", "sad"];
|
|
2
|
+
let customCensorWords = [];
|
|
3
|
+
|
|
4
|
+
function addCensoredWord(word){
|
|
5
|
+
customCensorWords.push(word);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function censor(textStr){
|
|
9
|
+
for(let idx in censoredWords){
|
|
10
|
+
textStr = textStr.replace(censoredWords[idx], "***");
|
|
11
|
+
}
|
|
12
|
+
for(let idx in customCensorWords){
|
|
13
|
+
textStr = textStr.replace(customCensorWords[idx], "***");
|
|
14
|
+
}
|
|
15
|
+
return textStr;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getCensoredWords(){
|
|
19
|
+
const rCensoredWords = [...censoredWords, ...customCensorWords];
|
|
20
|
+
return rCensoredWords;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.addCensoredWord = addCensoredWord;
|
|
25
|
+
exports.getCensoredWords = getCensoredWords;
|
|
26
|
+
exports.censor = censor;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bharanidharan-alt/censorify",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A library to censor inappropriate words and replace them with asteriks",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Bharanidharan",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "censortext.js",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": "*"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Bharanidharan2006/censorify_fst_lab.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"censor",
|
|
18
|
+
"words"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {}
|
|
21
|
+
}
|