mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
8c91f5c0d8
both in memory and on disk
23 lines
742 B
JavaScript
23 lines
742 B
JavaScript
module.exports = function(RED) {
|
|
"use strict";
|
|
var sentiment = require('sentiment');
|
|
|
|
function SentimentNode(n) {
|
|
RED.nodes.createNode(this,n);
|
|
this.property = n.property||"payload";
|
|
var node = this;
|
|
|
|
this.on("input", function(msg) {
|
|
var value = RED.util.getMessageProperty(msg,node.property);
|
|
if (value !== undefined) {
|
|
sentiment(value, msg.overrides || null, function (err, result) {
|
|
msg.sentiment = result;
|
|
node.send(msg);
|
|
});
|
|
}
|
|
else { node.send(msg); } // If no matching property - just pass it on.
|
|
});
|
|
}
|
|
RED.nodes.registerType("sentiment",SentimentNode);
|
|
}
|