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.1.1 to 1.1.2

package-lock.json

70

index.js

@@ -1,3 +0,3 @@

/**
* no-swears - Filer our swear words from your strings
/**
* no-swears - Filter out or detect swear words in your strings
*

@@ -9,43 +9,43 @@ * @author Gabriel Simmer <https://github.com/gmemstr>

'use strict'
"use strict";
const fs = require('fs')
const path = require('path')
const fs = require("fs");
const path = require("path");
module.exports = {
/**
/**
* Replaces bad words with asterisks
**/
filter: (words, callback) => {
var finalString = words
swearList(lines => {
for (var i = 0; i < lines.length; i++) {
var bw = new RegExp(lines[i], 'gi')
finalString = finalString.replace(bw, '****')
}
callback(finalString)
});
},
/**
filter: (words, callback) => {
var finalString = words;
swearList(lines => {
for (var i = 0; i < lines.length; i++) {
var bw = new RegExp(lines[i], "gi");
finalString = finalString.replace(bw, "*".repeat(lines[i].length));
}
callback(finalString);
});
},
/**
* True if swearword is found, false if not
**/
hasSwears: (words, callback) => {
swearList(lines =>{
var b = false
for (var i = 0; i < lines.length; i++) {
if(words.indexOf(lines[i]) > -1) {
b = true
}
}
callback(b)
});
}
}
hasSwears: (words, callback) => {
swearList(lines => {
var b = false;
for (var i = 0; i < lines.length; i++) {
if (words.indexOf(lines[i]) > -1) {
b = true;
}
}
callback(b);
});
}
};
var swearList = callback => {
fs.readFile(path.join(__dirname,'swearwords.txt'), 'utf8', (err, data) => {
if (err) throw err
data = data.replace(new RegExp('\r','g'),'').split('\n')
callback(data)
});
}
fs.readFile(path.join(__dirname, "swearwords.txt"), "utf8", (err, data) => {
if (err) throw err;
data = data.replace(new RegExp("\r", "g"), "").split("\n");
callback(data);
});
};
{
"name": "no-swears",
"version": "1.1.1",
"version": "1.1.2",
"description": "Filter swearwords out of your strings automagically",

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

@@ -13,2 +13,6 @@ no-swears

```bash
npm install --save no-swears
```
```javascript

@@ -15,0 +19,0 @@ 'use strict'

@@ -1,23 +0,28 @@

'use strict'
"use strict";
const noswears = require('./index')
const noswears = require("./index");
let badString = "hell brainfuck is weird"
let badString = "hell brainfuck is a weird bitch";
noswears.filter(badString, goodString => {
console.log("Testing filter\nWant string \"**** brain**** is weird\", got", goodString)
if (goodString == "**** brain**** is weird") {
console.log("✔ Success!")
} else {
console.log("✖ Failed!")
}
})
var expected = "**** brain**** is a weird *****";
console.log(
'Testing filter\nWant string "' + expected + '", got',
goodString
);
if (goodString == expected) {
console.log("✔ Success!");
} else {
console.log("✖ Failed!");
}
});
noswears.hasSwears(badString, swearBool => {
console.log("\nTesting hasSwears\nWant true, got", swearBool)
if (swearBool == true) {
console.log("✔ Success!")
} else {
console.log("✖ Failed!")
}
})
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