Skip to content

Commit 6e72697

Browse files
committed
trying to reduce complexity
1 parent 43fd29f commit 6e72697

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • services/tone_analyzer

services/tone_analyzer/v3.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ module.exports = function (RED) {
5656
var sentences = msg.sentences || config.sentences;
5757
var contentType = msg.contentType || config.contentType
5858

59+
callToneAnalyzer(username, password, msg, tones, sentences, contentType);
60+
});
61+
62+
var callToneAnalyzer = function(username, password, msg, tones, sentences, contentType) {
5963
var watson = require('watson-developer-cloud');
6064

6165
var tone_analyzer = watson.tone_analyzer({
@@ -75,7 +79,7 @@ module.exports = function (RED) {
7579
}
7680

7781
// Payload (text to be analysed) must be a string (content is either raw string or Buffer)
78-
if (typeof msg.payload === 'string' || isBuffer === true ) {
82+
if (typeof msg.payload === 'string' || isBuffer === true) {
7983
var options = {
8084
text: msg.payload,
8185
sentences: sentences,
@@ -97,14 +101,14 @@ module.exports = function (RED) {
97101

98102
node.send(msg);
99103
});
100-
}
101-
else {
104+
} else {
102105
message = 'The payload must be either a string or a Buffer';
103106
node.status({fill:'red', shape:'dot', text:message});
104107
node.error(message, msg);
105108
}
106-
});
109+
}
107110
}
111+
108112
RED.nodes.registerType('watson-tone-analyzer-v3', Node, {
109113
credentials: {
110114
username: {type:'text'},

0 commit comments

Comments
 (0)