Socket
Socket
Sign inDemoInstall

censoring

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

censoring.test.js

16

index.js

@@ -14,3 +14,3 @@ ;

*
* @type {String}
* @type {String|function(match: string): string}
*/

@@ -234,7 +234,7 @@ this.replacementString = '***';

*
* @param {String} str
* @param {String|function(match: string): string} str
* @returns {Censoring}
*/
setReplacementString: function (str) {
if (typeof str !== 'string') {
if (typeof str !== 'string' && typeof str !== 'function') {
throw 'Invalid replacementString type supplied. Expected string.';

@@ -249,3 +249,3 @@ }

/**
* @returns {String}
* @returns {String|function(match: string): string}
*/

@@ -269,3 +269,3 @@ getReplacementString: function () {

* @param {String} str
* @param {Boolean} highlight
* @param {Boolean} [highlight]
* @returns {Censoring}

@@ -293,3 +293,3 @@ */

* @param {String} str
* @param {Boolean} highlight
* @param {Boolean} [highlight]
* @returns {String}}

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

self.currentMatch.matches.push(match);
if (typeof self.replacementString === 'function') {
return self.replacementString(match);
}
return self.replacementString;

@@ -308,0 +312,0 @@ });

{
"name": "censoring",
"version": "1.0.1",
"version": "1.1.0",
"description": "Censor or highlight words and other patterns intelligently.",

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

@@ -95,3 +95,3 @@ # Censoring

scan.enableFilter('words');
scan.addFilterWord(['stoopid head', 'big meany']);
scan.addFilterWords(['stoopid head', 'big meany']);
```

@@ -109,4 +109,4 @@

### .setReplacementString(string replacementString)
Set the string to replace matches with. Defaults to `***`.
### .setReplacementString(string|function(match: string):string replacementString)
Set a replacement function, or set a string to replace matches with. Defaults to `***`.

@@ -117,2 +117,3 @@ ```javascript

scan.setReplacementString('pony');
scan.setReplacementString((match) => '*'.repeat(match.length));
```

@@ -188,3 +189,3 @@

scan.enableFilter('words');
scan.addFilterWord(['stoopid head', 'big meany']);
scan.addFilterWords(['stoopid head', 'big meany']);

@@ -191,0 +192,0 @@ result = scan.filterString(testString);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc