New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

no-swears

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

no-swears - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

21

index.js

@@ -17,6 +17,2 @@ /**

* Replaces bad words with asterisks
*
* @param {string} words - String of words to filter
*
* @returns {string} String of words (censored).
**/

@@ -35,3 +31,20 @@ filter: (words, callback) => {

});
},
/**
* True if swearword is found, false if not
**/
hasSwears: (words, callback) => {
fs.readFile(path.join(__dirname,'swearwords.txt'), 'utf8', (err, data) => {
if (err) throw err
var b = false
// Trim down file input to remove weird encoding/returns
var lines = data.replace(new RegExp('\r','g'),'').split('\n')
for (var i = 0; i < lines.length; i++) {
if(words.indexOf(lines[i]) > -1) {
b = true
}
}
callback(b)
});
}
}

2

package.json
{
"name": "no-swears",
"version": "1.0.2",
"version": "1.1.0",
"description": "Filter swearwords out of your strings automagically",

@@ -5,0 +5,0 @@ "main": "index.js",

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

no-swears
no-swears
===

@@ -6,2 +6,4 @@

[![npm version](https://badge.fury.io/js/no-swears.svg)](https://badge.fury.io/js/no-swears)
Very simple package for censoring swear words from JavaScript strings,

@@ -27,6 +29,17 @@ replacing offending words with "\*\*\*\*".

noswears.filter(badString, goodString => {
console.log(goodString)
console.log(goodString) // "this is a ****ing string"
})
```
More options coming soon :)
### hasSwears()
This just returns true or false to callback depending on whether the passed string
contains a swear word
```javascript
let badString = "this is a bitching string"
noswears.hasSwears(badString, swearBool => {
console.log(swearBool) // true
})
```

@@ -8,3 +8,3 @@ 'use strict'

noswears.filter(badString, goodString => {
console.log("Want string \"**** brain**** is weird\", got", goodString)
console.log("Testing filter\nWant string \"**** brain**** is weird\", got", goodString)
if (goodString == "**** brain**** is weird") {

@@ -15,2 +15,11 @@ console.log("✔ Success!")

}
})
noswears.hasSwears(badString, swearBool => {
console.log("\nTesting hasSwears\nWant true, got", swearBool)
if (swearBool == true) {
console.log("✔ Success!")
} else {
console.log("✖ Failed!")
}
})
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