@2toad/profanity
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -23,18 +23,21 @@ "use strict"; | ||
return text.replace(this.regex, this.options.grawlix); | ||
case models_1.CensorType.FirstChar: | ||
for (const match of text.matchAll(this.regex)) { | ||
case models_1.CensorType.FirstChar: { | ||
let output = text; | ||
Array.from(text.matchAll(this.regex)).forEach((match) => { | ||
const word = match[0]; | ||
const grawlix = this.options.grawlixChar + word.slice(1, word.length); | ||
text = text.replace(word, grawlix); | ||
} | ||
return text; | ||
output = output.replace(word, grawlix); | ||
}); | ||
return output; | ||
} | ||
case models_1.CensorType.FirstVowel: | ||
case models_1.CensorType.AllVowels: { | ||
const regex = new RegExp("[aeiou]", censorType === models_1.CensorType.FirstVowel ? "i" : "ig"); | ||
for (const match of text.matchAll(this.regex)) { | ||
let output = text; | ||
Array.from(text.matchAll(this.regex)).forEach((match) => { | ||
const word = match[0]; | ||
const grawlix = word.replace(regex, this.options.grawlixChar); | ||
text = text.replace(word, grawlix); | ||
} | ||
return text; | ||
output = output.replace(word, grawlix); | ||
}); | ||
return output; | ||
} | ||
@@ -41,0 +44,0 @@ default: |
{ | ||
"name": "@2toad/profanity", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "A JavaScript profanity filter", | ||
@@ -14,11 +14,11 @@ "homepage": "https://github.com/2Toad/Profanity", | ||
"scripts": { | ||
"local": "npx tsc --watch", | ||
"lint": "npx eslint src --cache", | ||
"lint:fix": "npx eslint src --cache --fix", | ||
"prettier": "npx prettier --write .", | ||
"test": "mocha -r ts-node/register src/**/*.spec.ts", | ||
"clean": "npx rimraf dist", | ||
"build": "npm run clean && npx tsc", | ||
"deploy": "npm publish", | ||
"prepublishOnly": "npm run lint && npm run test && npm run build" | ||
"local": "npm run build && concurrently -p \"none\" \"npx tsc --watch\" \"nodemon -q dist/index.js\"", | ||
"test": "mocha -r ts-node/register -r mocha-suppress-logs tests/**/*.spec.ts", | ||
"lint": "eslint . --cache", | ||
"lint:fix": "eslint . --cache --fix", | ||
"prettier": "prettier --check **/*.ts", | ||
"prettier:fix": "prettier --write **/*.ts", | ||
"prepublishOnly": "npm run lint && npm run prettier && npm test && npm run build" | ||
}, | ||
@@ -48,14 +48,23 @@ "repository": { | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^17.0.31", | ||
"@typescript-eslint/eslint-plugin": "^5.22.0", | ||
"@typescript-eslint/parser": "^5.22.0", | ||
"@types/node": "^17.0.36", | ||
"@typescript-eslint/eslint-plugin": "^5.26.0", | ||
"@typescript-eslint/parser": "^5.26.0", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.15.0", | ||
"concurrently": "^7.2.1", | ||
"eslint": "^8.16.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^17.0.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-security": "^1.5.0", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^12.4.1", | ||
"mocha": "^10.0.0", | ||
"prettier": "2.6.2", | ||
"mocha": "^9.2.2", | ||
"mocha-suppress-logs": "^0.3.1", | ||
"nodemon": "^2.0.16", | ||
"prettier": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.6.4" | ||
"ts-node": "^10.8.0", | ||
"typescript": "^4.7.2" | ||
}, | ||
@@ -62,0 +71,0 @@ "lint-staged": { |
@@ -17,2 +17,4 @@ # Profanity | ||
>if you're using Node 11.x or older you'll need to install [Profanity 1.x](https://github.com/2Toad/Profanity/releases) (e.g., `npm i @2toad/profanity@1.4.0`) | ||
## Usage | ||
@@ -124,1 +126,5 @@ | ||
``` | ||
## Contributing | ||
So you want to contribute to the Profanikty project? Fantastic! Please read the [Contribute](https://github.com/2Toad/Profanity/blob/master/contribute.md) doc to get started. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
128
33800
23
28
656