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

bad-words-next

Package Overview
Dependencies
Maintainers
1
Versions
58
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.3.5 to 1.3.6

76

lib/index.js

@@ -12,3 +12,2 @@ 'use strict';

var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {

@@ -20,6 +19,4 @@ var symbols = Object.getOwnPropertySymbols(object);

}
return keys;
}
function _objectSpread2(target) {

@@ -34,6 +31,4 @@ for (var i = 1; i < arguments.length; i++) {

}
return target;
}
function _classCallCheck(instance, Constructor) {

@@ -44,3 +39,2 @@ if (!(instance instanceof Constructor)) {

}
function _defineProperties(target, props) {

@@ -55,3 +49,2 @@ for (var i = 0; i < props.length; i++) {

}
function _createClass(Constructor, protoProps, staticProps) {

@@ -65,3 +58,2 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _defineProperty(obj, key, value) {

@@ -78,6 +70,4 @@ if (key in obj) {

}
return obj;
}
function _unsupportedIterableToArray(o, minLen) {

@@ -91,14 +81,9 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {

@@ -108,5 +93,3 @@ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

var i = 0;
var F = function () {};
return {

@@ -129,9 +112,7 @@ s: F,

}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
didErr = false,
err;
return {

@@ -169,3 +150,2 @@ s: function () {

}
function escapeRegexpString(str) {

@@ -184,5 +164,5 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

var BadWordsNext = function () {
function BadWordsNext(opts) {
_classCallCheck(this, BadWordsNext);
this.opts = opts !== undefined ? _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), opts) : DEFAULT_OPTIONS;

@@ -197,3 +177,2 @@ this.specialChars = this.opts.specialChars.toString().slice(1, -1);

this.clear = memoized.clear;
if (this.opts.data !== undefined) {

@@ -206,10 +185,9 @@ this.add(this.opts.data);

key: "add",
value: function add(data) {
value:
function add(data) {
this.clear();
var regexp = '';
var lookalike = '';
var _iterator = _createForOfIteratorHelper(data.words),
_step;
_step;
try {

@@ -220,17 +198,12 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) {

if (exp === '') continue;
if (exp.startsWith('*')) {
exp = "[^\\s\\b^]*".concat(exp.slice(1));
}
if (exp.endsWith('*')) {
exp = "".concat(exp.slice(0, -1), "[^\\s\\b$]*");
}
regexp += regexp !== '' ? "|".concat(exp) : exp;
if (exp.includes('_')) {
var _iterator2 = _createForOfIteratorHelper(this.opts.spaceChars),
_step2;
_step2;
try {

@@ -253,3 +226,2 @@ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {

}
for (var _key in data.lookalike) {

@@ -259,20 +231,17 @@ var esc = escapeRegexpString(_key);

}
this.data[data.id] = _objectSpread2(_objectSpread2({}, data), {}, {
wordsRegexp: this.regexp(regexp)
});
if (lookalike !== '') {
this.data[data.id].lookalikeRegexp = new RegExp(lookalike, 'ig');
}
this.ids.push(data.id);
}
}, {
key: "prepare",
value: function prepare(str, id) {
value:
function prepare(str, id) {
var _this = this;
var s = str;
if (this.data[id].lookalikeRegexp !== undefined) {

@@ -283,30 +252,28 @@ s = str.replace(this.data[id].lookalikeRegexp, function (m) {

}
var ml = m.toLowerCase();
if (_this.data[id].lookalike[ml] !== undefined) {
return _this.data[id].lookalike[ml];
}
return m;
});
}
return this.opts.confusables.includes(id) ? confusables.remove(s) : s;
}
}, {
key: "regexp",
value: function regexp(expr) {
value:
function regexp(expr) {
return new RegExp("(?:^|\\b|\\s)(?:".concat(this.specialChars, ")*(?:").concat(expr, ")(?:").concat(this.specialChars, ")*(?:$|\\b|\\s)"), 'i');
}
}, {
key: "check",
value: function check(str) {
value:
function check(str) {
var _iterator3 = _createForOfIteratorHelper(this.ids),
_step3;
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var id = _step3.value;
if (this.data[id].wordsRegexp.test(str) || this.data[id].wordsRegexp.test(this.prepare(str, id))) {

@@ -321,10 +288,10 @@ return true;

}
return false;
}
}, {
key: "filter",
value: function filter(str) {
value:
function filter(str) {
var _this2 = this;
if (str === '' || this.check(str) === false) return str;

@@ -334,7 +301,5 @@ var delims = [];

var match;
while ((match = re.exec(str)) !== null) {
delims.push(match[0]);
}
return str.split(/[\b\s]/).map(function (p) {

@@ -347,3 +312,2 @@ return _this2.check(p) === true ? _this2.opts.placeholder : p;

}]);
return BadWordsNext;

@@ -350,0 +314,0 @@ }();

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

@@ -42,24 +42,24 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.19.1",
"@babel/plugin-transform-typescript": "^7.19.1",
"@babel/preset-env": "^7.19.1",
"@babel/core": "^7.19.6",
"@babel/plugin-transform-typescript": "^7.19.3",
"@babel/preset-env": "^7.19.4",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-babel": "^5.3.1",
"@types/jest": "^29.0.3",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"eslint": "^8.24.0",
"@types/jest": "^29.2.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"eslint": "^8.26.0",
"eslint-config-standard-with-typescript": "^23.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.3.0",
"eslint-plugin-promise": "^6.0.1",
"jest": "^29.0.3",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.2.2",
"rollup": "^2.79.1",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "^4.2.2",
"typedoc": "^0.23.15",
"rollup-plugin-dts": "^4.2.3",
"typedoc": "^0.23.18",
"typedoc-github-wiki-theme": "^1.0.1",
"typedoc-plugin-markdown": "^3.13.6",
"typedoc-plugin-rename-defaults": "^0.6.4",
"typescript": "^4.8.3"
"typescript": "^4.8.4"
},

@@ -66,0 +66,0 @@ "dependencies": {

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