mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
18 lines
505 B
JavaScript
18 lines
505 B
JavaScript
|
|
module.exports = function(RED) {
|
|
"use strict";
|
|
|
|
function BadwordsNode(n) {
|
|
RED.nodes.createNode(this,n);
|
|
var badwordsRegExp = require('badwords/regexp');
|
|
var node = this;
|
|
node.on("input", function(msg) {
|
|
if (typeof msg.payload === "string") {
|
|
badwordsRegExp.lastIndex = 0
|
|
if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); }
|
|
}
|
|
});
|
|
}
|
|
RED.nodes.registerType("badwords",BadwordsNode);
|
|
}
|