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

bad-words

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bad-words - npm Package Compare versions

Comparing version 1.3.1 to 1.4.1

test/removeWords.js

13

lib/badwords.js
var Filter = (function() {
function Filter(options) {
options = options || {};
this.list = Array.prototype.concat.apply(require('./lang.json').words, [require('badwords-list').array, options.list || []]);
this.list = options.emptyList && [] || Array.prototype.concat.apply(require('./lang.json').words, [require('badwords-list').array, options.list || []]);
this.placeHolder = options.placeHolder || '*';

@@ -35,2 +35,13 @@ this.regex = options.regex || /[^a-zA-z0-9|\$|\@]|\^/g;

Filter.prototype.removeWords = function removeWords() {
words = Array.prototype.slice.call(arguments);
words.map(function(word) {
return this.list.indexOf(word);
}, this).filter(function(index) {
return !!~index;
}).forEach(function(index){
this.list.splice(index, 1);
}, this);
};
return Filter;

@@ -37,0 +48,0 @@ })();

2

package.json
{
"name": "bad-words",
"version": "1.3.1",
"version": "1.4.1",
"description": "A javascript filter for bad words",

@@ -5,0 +5,0 @@ "main": "./lib/badwords",

@@ -1,2 +0,2 @@

# bad-words v1.1.0
# bad-words
A javascript filter for badwords

@@ -46,2 +46,17 @@

### Instantiate with an empty list
```
var filter = new Filter({ emptyList: true });
filter.clean('hell this wont clean anything'); //hell this wont clean anything
```
### Remove words from the blacklist
```
var filter = new Filter();
filter.removeWords('hells');
filter.clean("some hells word!"); //some hells word!
```
## Testing

@@ -52,6 +67,8 @@ ```

##Release Notes
## Release Notes
- v1.1.0 / Mar 17 2015: Added soundex support for comparing words to things not in the list.
- v1.2.0 / May 29 2015: Removed soundex logic which resulted in many false positives within the isProfane test.
- v1.3.0 / Oct 1 2015: Updated local list and documentation. Added ability to pass a custom list of words during construction.
- v1.4.0 / Sept 2 2016: Added removeWords feature. Added emptyList configuration parameter.
- v1.4.1 / Sept 2 2016: Updated documentation.

@@ -58,0 +75,0 @@

@@ -24,3 +24,10 @@ require('assert');

});
it('Should allow an instance of filter with an empty blacklist', function() {
var customFilter = new Filter({
emptyList: true
});
assert(customFilter.clean('This is a hells good test') === 'This is a hells good test');
});
});
});
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