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.1.6 to 1.2.0

2

doc/_Sidebar.md

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

## bad-words-next - v1.1.5
## bad-words-next - v1.1.6
- [Home](../wiki/Home)

@@ -33,3 +33,3 @@ # Class: BadWordsNext

[index.ts:174](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L174)
[index.ts:172](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L172)

@@ -56,3 +56,3 @@ ## Methods

[index.ts:196](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L196)
[index.ts:195](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L195)

@@ -79,3 +79,3 @@ ___

[index.ts:264](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L264)
[index.ts:265](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L265)

@@ -102,2 +102,2 @@ ___

[index.ts:279](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L279)
[index.ts:280](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L280)

@@ -23,3 +23,3 @@ # Interface: Data

[index.ts:27](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L27)
[index.ts:27](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L27)

@@ -36,3 +36,3 @@ ___

[index.ts:39](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L39)
[index.ts:39](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L39)

@@ -49,2 +49,2 @@ ___

[index.ts:33](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L33)
[index.ts:33](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L33)

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

# bad-words-next - v1.1.5
# bad-words-next - v1.1.6

@@ -3,0 +3,0 @@ ## Table of contents

@@ -30,3 +30,3 @@ # Interface: Options

[index.ts:83](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L83)
[index.ts:76](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L76)

@@ -43,3 +43,3 @@ ___

[index.ts:57](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L57)
[index.ts:50](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L50)

@@ -60,3 +60,3 @@ ___

[index.ts:90](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L90)
[index.ts:83](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L83)

@@ -77,3 +77,3 @@ ___

[index.ts:64](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L64)
[index.ts:57](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L57)

@@ -90,7 +90,7 @@ ___

<code>['', '.', '-', '_', ';', '|']</code>
<code>['', '.', '-', ';', '|']</code>
#### Defined in
[index.ts:77](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L77)
[index.ts:70](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L70)

@@ -111,2 +111,2 @@ ___

[index.ts:71](https://github.com/alexzel/bad-words-next/blob/d75ca3d/src/index.ts#L71)
[index.ts:64](https://github.com/alexzel/bad-words-next/blob/4640441/src/index.ts#L64)

@@ -35,8 +35,2 @@ /**

/**
* Dictionaries data map
*/
interface DataMap {
[key: string]: Data;
}
/**
* Constructor options

@@ -64,3 +58,3 @@ */

* Pseudo space chars, a list of values for `_` symbol replacement in a dictionary word string
* @defaultValue <code>['', '.', '-', '_', ';', '|']</code>
* @defaultValue <code>['', '.', '-', ';', '|']</code>
*/

@@ -81,6 +75,6 @@ spaceChars?: string[];

/**
* Required constructor options for internal store
* Internal options with required properties
*/
interface RequiredOptions {
data: Data;
interface InternalOptions {
data?: Data;
placeholder: string;

@@ -93,9 +87,18 @@ specialChars: RegExp;

/**
* Internal word representation
* Internal dictionaries data format
*/
interface Word {
id: string;
expr: string;
interface InternalData extends Data {
/**
* Regular expression for dictionary words
* @type {RegExp}
*/
regexp: RegExp;
}
/**
* Internal dictionaries data map
*/
interface InternalDataMap {
[key: string]: InternalData;
}
/**
* Main library class implementing profanity filtering and detection

@@ -109,3 +112,3 @@ */

*/
opts: RequiredOptions;
opts: InternalOptions;
/**

@@ -118,7 +121,7 @@ * Special chars represented as string from specialChars regular expression

/**
* Words list arrived from dictionaries data
* Dictionaries ids list
* @private
* @type {Word[]}
* @type {string[]}
*/
words: Word[];
ids: string[];
/**

@@ -129,3 +132,3 @@ * Dictionaries data map with data ID as a key

*/
data: DataMap;
data: InternalDataMap;
/**

@@ -132,0 +135,0 @@ * Clear memoized check

@@ -159,10 +159,5 @@ 'use strict';

var DEFAULT_OPTIONS = {
data: {
id: 'default',
words: [],
lookalike: {}
},
placeholder: '***',
specialChars: /\d|[!@#$%^&*()[\];:'",.?\-_=+~`|]|a|(?:the)|(?:el)|(?:la)/,
spaceChars: ['', '.', '-', '_', ';', '|'],
spaceChars: ['', '.', '-', ';', '|'],
confusables: ['en', 'es', 'de'],

@@ -189,5 +184,5 @@ maxCacheSize: 100

/**
* Words list arrived from dictionaries data
* Dictionaries ids list
* @private
* @type {Word[]}
* @type {string[]}
*/

@@ -217,4 +212,4 @@

this.specialChars = this.opts.specialChars.toString().slice(1, -1);
this.words = [];
this.data = {};
this.ids = [];
var memoized = memoize__default["default"](this.check, {

@@ -225,3 +220,6 @@ max: this.opts.maxCacheSize

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

@@ -239,3 +237,3 @@ /**

this.clear();
this.data[data.id] = data;
var regexp = '';

@@ -259,6 +257,3 @@ var _iterator = _createForOfIteratorHelper(data.words),

this.words.push({
id: data.id,
expr: exp
});
regexp += regexp !== '' ? "|".concat(exp) : exp;

@@ -272,6 +267,3 @@ if (exp.includes('_')) {

var ch = _step2.value;
this.words.push({
id: data.id,
expr: exp.replace(/_/g, ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
});
regexp += "|".concat(exp.replace(/_/g, ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
}

@@ -290,2 +282,7 @@ } catch (err) {

}
this.data[data.id] = _objectSpread2(_objectSpread2({}, data), {}, {
regexp: this.regexp(regexp)
});
this.ids.push(data.id);
}

@@ -322,3 +319,3 @@ /**

value: function regexp(expr) {
return new RegExp("(?:^|\\b|\\s)(?:".concat(this.specialChars, ")*").concat(expr, "(?:").concat(this.specialChars, ")*(?:$|\\b|\\s)"), 'i');
return new RegExp("(?:^|\\b|\\s)(?:".concat(this.specialChars, ")*(?:").concat(expr, ")(?:").concat(this.specialChars, ")*(?:$|\\b|\\s)"), 'i');
}

@@ -335,3 +332,3 @@ /**

value: function check(str) {
var _iterator3 = _createForOfIteratorHelper(this.words),
var _iterator3 = _createForOfIteratorHelper(this.ids),
_step3;

@@ -341,5 +338,5 @@

for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var word = _step3.value;
var id = _step3.value;
if (this.regexp(word.expr).test(str) || this.regexp(word.expr).test(this.prepare(str, word.id))) {
if (this.data[id].regexp.test(str) || this.data[id].regexp.test(this.prepare(str, id))) {
return true;

@@ -346,0 +343,0 @@ }

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

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

@@ -84,3 +84,3 @@ # bad-words-next

specialChars?: RegExp // Special chars to allow on word start and word end - default value /\d|[!@#$%^&*()[\];:'",.?\-_=+~`|]|a|(?:the)|(?:el)|(?:la)/
spaceChars?: string[] // Pseudo space chars, a list of values for `_` symbol in a dictionary word string - default value ['', '.', '-', '_', ';', '|']
spaceChars?: string[] // Pseudo space chars, a list of values for `_` symbol in a dictionary word string - default value ['', '.', '-', ';', '|']
confusables?: string[] // List of ids to apply transformations from `confusables` npm package - default ['en', 'es', 'de']

@@ -93,6 +93,4 @@ maxCacheSize?: number // Max items to store in cache - default value 100

- Filtering may be potentially slow on large strings and large dictionaries
- Dictionary words with spaces won't work
- Dictionaries have to be improved over time

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