Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bad-words-next

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bad-words-next - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

3

lib/index.d.ts

@@ -171,7 +171,8 @@ /**

* @param {string}
* @param {(badword: string) => void}
* @return {string}
*/
filter(str: string): string;
filter(str: string, onBadword?: (badword: string) => void): string;
}
export { Data, Lookalike, Options, BadWordsNext as default };

@@ -278,3 +278,3 @@ 'use strict';

key: "filter",
value: function filter(str) {
value: function filter(str, onBadword) {
var _this2 = this;

@@ -289,3 +289,9 @@ if (str === '' || this.check(str) === false) return str;

return str.split(/[\b\s]/).map(function (p) {
return _this2.check(p) === true ? _this2.opts.placeholder : p;
if (_this2.check(p) === true) {
if (onBadword !== undefined) {
onBadword(p);
}
return _this2.opts.placeholder;
}
return p;
}).reduce(function (a, s, i) {

@@ -292,0 +298,0 @@ return a + (i > 0 ? delims[i - 1] === undefined ? ' ' : delims[i - 1] : '') + s;

{
"name": "bad-words-next",
"version": "1.5.3",
"version": "1.6.0",
"description": "JavaScript/TypeScript filter and checker for bad words aka profanity",

@@ -5,0 +5,0 @@ "keywords": [

@@ -41,2 +41,8 @@ # bad-words-next

// will print `S0me *** is here`
// Returns filtered string and catches bad words
badwords.filter('S0me sh!tt is here', badword => {
console.log(badword)
})
// will print `sh!tt`
```

@@ -43,0 +49,0 @@

@@ -53,2 +53,11 @@ import BadWordsNext from '../src'

})
it('filters and reports back with callback function', () => {
const badwords = new BadWordsNext({ data: en })
const detected: string[] = []
badwords.filter('hello sex sex3 b0000b test b00b anyfuckany pussy cat', (badword: string) => {
detected.push(badword)
})
expect(detected).toStrictEqual(['sex', 'sex3', 'b0000b', 'b00b', 'anyfuckany', 'pussy'])
})
})

@@ -55,0 +64,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc